Thursday, November 26, 2009

JAX-WS Fighting with com.sun.xml.ws.server.UnsupportedMediaException

So I was running a JAX-WS stub from my application and kept getting this exception:


Exception: ------
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html; charset=ISO-8859-1 Supported ones are: [text/xml]
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:295)
...


Its pretty obvious to see that the webservice is expecting XML/SOAP back as a response but instead is getting HTML. It could be the firewall, our authenitication layer, a DNS error, a reverse proxy error, an application server error page... anything really.


What a terrible exception. Worse yet, as I am using the JAX-WS framework, there was no real way to find out what the html was in the response, or so I though. I spent more than a few hours trying to find out how. Finally, I found this little nugget... When starting up your application server java process, pass this in as a VM argument:


-Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump="true"

Now the response is spit out to stdout! Hope this helps anyone fighting the same problems.

Cheers,

Yeuker

No comments:

Post a Comment