I would like to access a third party websevice using a Java client that I generated with JAX-WS wsimport, based on the WSDL provided (I am using a Maven plugin).
For quite a while I was unable to retrieve a useful response, not in the Java client and also not in SoapUI, until I found out that I had to enable WS-A on the request. In SoapUI this now results in the expected response, but what must I do to also 'enable' WS-A in the Java client? Do I maybe have to alter the WSDL, or add a parameter to wsimport?
I found some documentation on WS-A online, but so far could not find an answer.
Thanks in advance.
You can modify the WSDL as you mentioned, to indicate addressing is required (though I would ask the 3rd party to, if their endpoint truly requires it..). See example 3-1 and 3-2 on the specification for this. You may need to regenerate your client (wsimport); of this I am not sure.
If you want to accomplish this programmatically, you can try obtaining your port and passing a javax.xml.ws.soap.AddressingFeature
as follows:
import javax.xml.ws.soap.AddressingFeature;
...
//however you are obtaining your service -
//perhaps @WebServiceRef or instantiation with WSDL location, etc
HelloWorldService service = ...
...
//true,true means enable Addressing, and indicate it is required
HelloWorld port = service.getHelloWorldPort(new AddressingFeature(true, true));
... call operations/methods on HelloWorld port
The javadoc for AddressingFeature may yield more insight as well.