I am using JAXWS to generate a WebService client for a Java Application we're building.
When JAXWS build its XMLs to use in SOAP protocol, it generates the following namespace prefix:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body ...>
<!-- body goes here -->
</env:Body>
</env:Envelope>
My problem is that my Counterpart (a big money transfer company) which manages the server my client is connecting to, refuses to accept the WebService call (please don't ask my why) unless the XMLNS (XML namepspace prefix is soapenv
). Like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body ...>
<!-- body goes here -->
</soapenv:Body>
</soapenv:Envelope>
So my question is:
Is there a way I command JAXWS (or any other Java WS client technology) to generate clients using soapenv
instead of env
as the XMLNS
prefix? Is there an API call to set this information?
Thanks!
Maybe it's late for you and I'm not sure if this may work, but you can try.
First you need to implement a SoapHandler and, in the
handleMessage
method you can modify theSOAPMessage
. I'm not sure if you can modify directly that prefix but you can try:Then you need to create a
HandlerResolver
:And finally you'll have to add your
HandlerResolver
to your client service:This post, while likely too late for the original poster, is intended to help others who may run into this. I had to solve this problem in the last few days. In particular, I needed to change the prefixes used in the SOAP envelope because the service provider required that the namespace prefixes conform to a very specific pattern. Conforming to this pattern required changing the namespace prefix for the envelope, header and body, and body elements (from the standard ones put in by JAX-WS). Here is an outline of the solution I used:
Setting the handler resolver above on an instance of the service class (generated by JAX-WS/wsimport) looks like this: