JaxWsDynamicClientFactory.newInstance().createClient() 和 wsdl2Java 不一致
所以我尝试使用 JaxWsDynamicClientFactory 动态创建 SEI 类。运行以下代码
JaxWsDynamicClientFactory def = JaxWsDynamicClientFactory.newInstance();
def.createClient("http://localhost:8080/TheTestService/TestService?wsdl");
生成类:
com.mycompany.project.service.GetProducts
com.mycompany.project.service.GetStatus
运行:
wsdl2Java -d "C/:outputdir" "http://localhost:8080/TheTestService/TestService?wsdl"
生成类
com.mycompany.project.service.ServiceInterface
com.mycompany.project.service.GetProducts
com.mycompany .project.service.GetStatus
com.mycompany.project.service.impl.ServiceInterface
此外,当我尝试调用时,
client.invoke("getProducts", 0);
我得到:
org.apache.cxf.common.i18n.UncheckedException: No operation was found with the name {http://impl.service.project.mycompany.com/}getProducts.
我认为这是有道理的,因为 impl.service.project.mycompany.com 不会生成任何名为 getProducts 的内容。然而,自从我编写了 Web 服务以来,我知道 Web 服务接口具有 getProducts(int id) 方法。
我在这里做错了什么?根据 CXF 文档,动态客户端工厂使用与 wsdl2Java 工具相同的代码生成器。如果是这样的话,为什么不生成相同的类呢?
谢谢,
查克
So I'm trying to use JaxWsDynamicClientFactory to dynamically create the SEI classes. Running the below code
JaxWsDynamicClientFactory def = JaxWsDynamicClientFactory.newInstance();
def.createClient("http://localhost:8080/TheTestService/TestService?wsdl");
generates classes:
com.mycompany.project.service.GetProducts
com.mycompany.project.service.GetStatus
running:
wsdl2Java -d "C/:outputdir" "http://localhost:8080/TheTestService/TestService?wsdl"
generates classes
com.mycompany.project.service.ServiceInterface
com.mycompany.project.service.GetProducts
com.mycompany.project.service.GetStatus
com.mycompany.project.service.impl.ServiceInterface
Furthermore, when I try to call
client.invoke("getProducts", 0);
I get:
org.apache.cxf.common.i18n.UncheckedException: No operation was found with the name {http://impl.service.project.mycompany.com/}getProducts.
which I guess makes sense as there would be nothing named getProducts generated at impl.service.project.mycompany.com. However since I wrote the web service, I know for a fact the web service interface has the method getProducts(int id).
What am I doing wrong here? According to the CXF documentation, the dynamic client factory uses the same code generator as the wsdl2Java tool. If that's the case, why aren't the same classes generated?
Thanks,
Chuck
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,
JaxWsProxyFactoryBean
创建一个Client就可以了。我解决了这个问题,你必须将你的服务接口和implementor
放在同一个类包中。当使用JaxWsDynamicClientFactory
动态创建 SEI 类时,它会在同一包路径中查找implementor
,这是默认设置。但根据 API,您可以设置您的targetNamespace
。我不知道
JaxWsProxyFactoryBean
和JaxWsDynamicClientFactory
之间的区别。First,
JaxWsProxyFactoryBean
to create a Client is ok. I solved the problem, you must keep your service interface andimplementor
in the same class package. WhenJaxWsDynamicClientFactory
is used to dynamically create the SEI classes, it would findimplementor
in the same package path, it is a default setting. But according to the API, you can set yourtargetNamespace
.I have no idea of the differences between
JaxWsProxyFactoryBean
andJaxWsDynamicClientFactory
.我认为存在一些错误,因为我有 .wsdl 并且使用 wsdl2java 生成的类之一具有属性
getItem
但已生成JaxWsDynamicClientFactory.newInstance().createClient()
这个类具有 getItems 属性。所以我的前进是检查您想要使用的类的方法(我的意思是,使用JaxWsDynamicClientFactory.newInstance().createClient()
生成的类的方法)。要实现此使用 refI think theare is some bug, cause i had .wsdl and one one of the classes generated with wsdl2java had property
getItem
BUTJaxWsDynamicClientFactory.newInstance().createClient()
has generated this class with property getItems. So my advance is to examine the methods of class you want use(i mean,methods of classes generated withJaxWsDynamicClientFactory.newInstance().createClient()
).To achive this use ref