如何将CXF Web服务使用的地址更改为与wsdl文件中指定的地址不同的地址? [英] How do I change the address used by a CXF Web Service to one different than the one specified in the wsdl file?

查看:246
本文介绍了如何将CXF Web服务使用的地址更改为与wsdl文件中指定的地址不同的地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我根据配置获得wsdl时,我已经开始工作了,但是我想告诉它使用特定地址进行服务调用并使用wsdl的本地副本。

I've got it working when I get the wsdl based on configuration, but I'd like to just tell it to use a specific address for the service call and use a local copy of the wsdl.

MyWebService serviceDefinition = new MyWebService(new URL(wsdlLocation));
service = serviceDefinition.getMyWebServicePort();

有谁知道这方面的最佳做法?

Does anyone know the best practice for this?

xml请求有效。

<soap:Body>
<ns2:getData xmlns:ns2="http://services.test.com/">
<arg0>Test Name</arg0>
<arg1>55555555</arg1>
</ns2:getData>
</soap:Body>

代理xml请求不起作用。

proxy xml request that doesn't work.

<soap:Body>
<ns1:getData xmlns:ns1="http://ws.test.com/">
<ns3:arg0 xmlns:ns2="http://services.test.com/" xmlns:ns3="http://ws.test.com/">Test Name</ns3:arg0>
<ns3:arg1 xmlns:ns2="http://services.test.com/" xmlns:ns3="http://ws.test.com/">55555555</ns3:arg1>
</ns1:getData>
</soap:Body>


推荐答案

你能否使用 ClientProxyFactoryBean ?如果您有已编译的存根,则甚至不需要WSDL。例如:

Can you use the ClientProxyFactoryBean? You don't even need the WSDL if you have the compiled stubs. For example:

ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:9000/Hello");
HelloWorld client = (HelloWorld) factory.create();

这篇关于如何将CXF Web服务使用的地址更改为与wsdl文件中指定的地址不同的地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆