1

My SOAP client is based on JAX-WS. The server (which is written and operated by someone else) usually returns valid XML messages, but occasionally, when it experiences an internal error, it returns an HTML message with an error code (HTTP 500).

Unfortunately, in this case the JAX-WS client merely throws an UnsupportedMediaException: "Unsupported Content-Type: text/html".

What I need now is a way to find out which error condition the server reports in order to take actions. I'd rather change the server, but that's not possible, as it is outside my reach.

At least, I need to log the incoming raw response.

I know that it is possible to log all requests and responses by following this advice: https://stackoverflow.com/a/5647686/578759

But this would probably overflow the system log, as we usually have several requests per second.

So instead I'd rather log the response only in case of an error.

We already have a SOAPHandler in place, which logs incoming and outgoing SOAP messages, but it works only on valid SOAP messages, i.e. after successfully parsing the XML. If the incoming response is HTML, we don't even get to the point where the handler is invoked.

Is there a way to add a similar handler at this stage?

Community
  • 1
  • 1
Hok
  • 847
  • 8
  • 16

1 Answers1

0

You can add a custom com.sun.xml.ws.api.pipe.TransportTubeFactory to access the raw InputStream of the HTTP response, see the last part of my answer on this question: UnsupportedMediaException -> how do you get the actual response?

slindenau
  • 1,091
  • 2
  • 11
  • 18