Question

I want to call an external SOAP web service using JaxWS. JaxWS sends a request in the form

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <messageRootElement xmlns="some.ns">
      <sampleChild>Content</sampleChild>
    </messageRootElement>
  </soap:Body>
</soap:Envelope>

Calling a mock service setup in SoapUI works fine. The actual external web service allegedly does not work with that format (I have no access to the system with the external web service for developement).

The external web service, seems to work with a request of the form

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sns="some.ns">
  <soap:Body>
    <sns:messageRootElement>
      <sns:sampleChild>Content</sns:sampleChild>
    </sns:messageRootElement>
  </soap:Body>
</soap:Envelope>

which is how SoapUI generates a sample request from the WSDL in question as well.

My question is: how do I tell JaxWS to send its request in the latter form? I assume, both are valid according to some standard, but I have not the slightest clue, what technology the external web service is based on, and how well it conforms to the involved standards.

Explaining to me that, it is not possible to change JaxWS behaviour in that way (if that is the case), would be a helpful answer as well.

Was it helpful?

Solution

You need to modify the package-info.java file that's generated as part of the entities that are required for your web service call. Modify the file as follows:

@javax.xml.bind.annotation.XmlSchema(
    namespace = "some.ns",
    elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
    xmlns = {
        @javax.xml.bind.annotation.XmlNs(
            prefix = "sns",
            namespaceURI = "some.ns")
    })

package some.ns;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top