3

当我根据配置获取 wsdl 时,我已经让它工作了,但我只想告诉它为服务调用使用特定地址并使用 wsdl 的本地副本。

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

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

xml 请求有效。

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

代理 xml 请求不起作用。

<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>
4

3 回答 3

10

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();
于 2009-09-14T14:48:36.763 回答
5
MyWebService serviceDefinition = new MyWebService(new URL(wsdlLocation));
service = serviceDefinition.getMyWebServicePort();

((BindingProvider)service).getRequestContext()
    .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/foobar");
于 2009-09-14T19:12:32.107 回答
3
JaxWsProxyFactoryBeanfactory = new JaxWsProxyFactoryBean();

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

JaxWS而不是 FactoryBeanfactory 前面的Client为我们工作。

于 2011-05-05T23:05:25.143 回答