wsimport:多个wsdl覆盖ObjectFactory [英] wsimport: multiple wsdl overwrite ObjectFactory
问题描述
我有多个(假设是2,A和B)webservices,我需要生成一个客户端来使用它们。
在Netbeans中,我使用向导new Web Service Client传递两个wsdl,查看输出Netbeans只需为每个wsmport调用wsimport。
I have multiple (let's say 2, A and B) webservices and I need to generate a client to use them togheter. In Netbeans I use the wizard "new Web Service Client" passing the two wsdl, looking at the output Netbeans simply call wsimport for each of them.
wsimport http:/mydomain/wsA.svc?wsdl
wsimport http:/mydomain/wsB.svc?wsdl
A和B都生成一个相同的包com.mydomain.myapp(我猜它们是在同一个命名空间中定义的),所以我得到了一个A类的存根类B合并在同一个包中。
Both A and B, generate a the same package com.mydomain.myapp (I guess they are defined in the same namespace), so I get the stub class set of A and B merged in the same package.
但是,wsimport还为每个web服务创建一个ObjectFactory,所以如果我在AI之后只生成与B定义相关的ObjectFactory,则生成B的存根(因为第一个,A,被覆盖)。相反,如果我切换顺序,A的ObjectFactory仍然存在。
However, wsimport also creates an ObjectFactory for each webservice so if I generate the stub of B after A I obtain only the ObjectFactory related to B definitions (because the first, A, is overwritten). Conversely, ObjectFactory of A survives if I switch the order.
问题是我需要两个ObjectFactories才能为两个webservices的类型创建JAXBElements包装clas实例A和B.
The problem is that I need both ObjectFactories in order to create the JAXBElements wrapping clas instances for the types of both webservices A and B.
有没有办法在Java包中映射A的名称空间,在另一个包中映射B以获取
Is there a way to map the namespace for A in a java package and the B in another one in order to obtain
com.mydomain.myapp.a
com.mydomain.myapp.b
所以同时保留两个ObjectFactories?
and so keep both ObjectFactories ?
简单的重构没有帮助,因为在内部调用了getClass(),一旦包被重构,它就不再起作用了。
Simple refactoring is not helping because internally a getClass() is called so, once a package has been refactored it does not work anymore.
推荐答案
你可以通过JAXB绑定文件来做到这一点 - 看看在这个问题/答案: java wsimport重命名/不同的ObjectFactory.java
You can probably do this via JAXB binding files - have a look at this question/answer: java wsimport rename/different ObjectFactory.java
从那个答案,看看在oracle的绑定文件中: http://docs.oracle。 com / javaee / 5 / tutorial / doc / bnbbf.html
From that answer, have a look at the binding file stuff at oracle: http://docs.oracle.com/javaee/5/tutorial/doc/bnbbf.html
这篇关于wsimport:多个wsdl覆盖ObjectFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!