Web services JaxWsDynamicClientFactory.newInstance().createClient()和wsdl2Java不一致
因此,我尝试使用JaxWsDynamicClientFactory动态创建SEI类。运行下面的代码Web services JaxWsDynamicClientFactory.newInstance().createClient()和wsdl2Java不一致,web-services,cxf,wsdl2java,Web Services,Cxf,Wsdl2java,因此,我尝试使用JaxWsDynamicClientFactory动态创建SEI类。运行下面的代码 JaxWsDynamicClientFactory def = JaxWsDynamicClientFactory.newInstance(); def.createClient("http://localhost:8080/TheTestService/TestService?wsdl"); 生成类: com.mycompany.project.service.GetProducts com.
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(intid)
我做错了什么?根据CXF文档,动态客户端工厂使用与wsdl2Java工具相同的代码生成器。如果是这样,为什么不生成相同的类
谢谢
Chuck我认为这是一个bug,因为我有.wsdl和一个用wsdl2java生成的类有属性
getItem
,但是JaxWsDynamicClientFactory.newInstance().createClient()
用属性getItems生成了这个类。因此,我的进步是检查您想要使用的类的方法(我的意思是,使用JaxWsDynamicClientFactory.newInstance().createClient()
)生成的类的方法)。要实现这一点,首先使用ref,JaxWsProxyFactoryBean
来创建客户机是可以的。我解决了这个问题,您必须将服务接口和实现者
放在同一个类包中。当使用JaxWsDynamicClientFactory
动态创建SEI类时,它会在相同的包路径中找到implementor
,这是默认设置。但是根据API,您可以设置targetNamespace
我不知道JaxWsProxyFactoryBean
和JaxWsDynamicClientFactory
之间的区别