JaxWsDynamicClientFactory.newInstance().createClient() 和 wsdl2Java 不一致

发布于 2024-10-30 14:41:03 字数 1200 浏览 0 评论 0原文

所以我尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小梨窩很甜 2024-11-06 14:41:03

首先,JaxWsProxyFactoryBean创建一个Client就可以了。我解决了这个问题,你必须将你的服务接口和implementor放在同一个类包中。当使用 JaxWsDynamicClientFactory 动态创建 SEI 类时,它会在同一包路径中查找 implementor,这是默认设置。但根据 API,您可以设置您的 targetNamespace

我不知道 JaxWsProxyFactoryBeanJaxWsDynamicClientFactory 之间的区别。

First, JaxWsProxyFactoryBean to create a Client is ok. I solved the problem, you must keep your service interface and implementor in the same class package. When JaxWsDynamicClientFactory is used to dynamically create the SEI classes, it would find implementor in the same package path, it is a default setting. But according to the API, you can set your targetNamespace.

I have no idea of the differences between JaxWsProxyFactoryBean and JaxWsDynamicClientFactory.

凉世弥音 2024-11-06 14:41:03

我认为存在一些错误,因为我有 .wsdl 并且使用 wsdl2java 生成的类之一具有属性 getItem 但已生成 JaxWsDynamicClientFactory.newInstance().createClient()这个类具有 getItems 属性。所以我的前进是检查您想要使用的类的方法(我的意思是,使用 JaxWsDynamicClientFactory.newInstance().createClient() 生成的类的方法)。要实现此使用 ref

I think theare is some bug, cause i had .wsdl and one one of the classes generated with wsdl2java had property getItem BUT JaxWsDynamicClientFactory.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 with JaxWsDynamicClientFactory.newInstance().createClient() ).To achive this use ref

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文