Forum Stats

  • 3,727,521 Users
  • 2,245,400 Discussions


Get raw soap message from soap context is not valid anymore

user10654662 Member Posts: 7

I've been dealing with webservices with XML signature over the last 10 years with no problem at all from both sides (client or server). But now, since java 1.8.141 our applications started to fail due invalid signature error.

We use handlers in order to "capture" de request (or response) and take the soap message in "raw". Signature process takes this raw message in order to calculate the hash. We have noticed that since 1.8.141, the received soap message from the soap context is different from the one that really goes via http.

To check this, we run one of our clients with the following parameters:

We use the "classical" code to get the raw soap message:

   public String getRawSoap(SOAPMessageContext context) throws IOException {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      SOAPMessage message = context.getMessage();
      return baos.toString(;

But we are facing this situation:

Raw response taken from http context (http headers have been removed for clarity, this is the debug output that we get with the previous said parameters)

    <?xml version='1.0' encoding='UTF-8'?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENC="" xmlns:SOAP-ENV="">
      <ResponseMessage xmlns="">
     . . . (more xml here)

Soap message that we get from SOAP Context:

   <SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:SOAP-ENC="" xmlns:env="">
    <SOAP-ENV:Body xmlns="">
        <Header xmlns="">
     . . . (more xml here)

Note that the namespace declarations now appears in different tags, so the xml has been modified and the signature (not shown in the example) is invalid.

We have created a java bug for this (JDK-8186441) but it has been marked as resolved for...version 10!. We need our system to work now, we cannot wait several months to get release 10.

Any help is appreciated.


This discussion has been closed.