views:

197

answers:

2

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 request that works.

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

proxy xml request that doesn't work.

<soap:Body>
<ns1:getData xmlns:ns1="http://ws.test.com/"&gt;
<ns3:arg0 xmlns:ns2="http://services.test.com/" xmlns:ns3="http://ws.test.com/"&gt;Test Name</ns3:arg0>
<ns3:arg1 xmlns:ns2="http://services.test.com/" xmlns:ns3="http://ws.test.com/"&gt;55555555&lt;/ns3:arg1&gt;
</ns1:getData>
</soap:Body>
+3  A: 

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();
Kevin
This worked in that it makes the web service call, but the arguments it passes cannot be read by the remote web service. The values are null when it gets to my method on the server side. The arguments are being sent (checked the xml being sent in the request).
ScArcher2
It was working 100% using the remote wsdl, not sure why this isn't working.
ScArcher2
What is the difference between the XML when using this method and the remote wsdl method?
Kevin
I updated my question with the xml sent by each method of requesting the web service. Thanks for your help I really appreciate it!
ScArcher2
You probably need the JAX-WS subclass of ClientProxyFactoryBean: JaxWsProxyFactoryBean. The basic ClientProxyFactoryBean woudln't know about the jaxws annotations and such that would probably be required in this case.
Daniel Kulp
Thanks Kevin and Daniel. That worked perfectly!
ScArcher2
A: 

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

((BindingProvider)service).getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/foobar");