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?

3
  • What is the operating environment of your client? Is it in a servlet? A standalone client etc Commented Mar 10, 2014 at 15:59
  • @kolossus The client runs as a Java 6 servlet in Tomcat 6 on Linux. Commented Apr 2, 2014 at 15:48
  • Are you still interested in sorting this out or did you find a solution? Commented Nov 4, 2014 at 21:01

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.