How to fix .NET Webservice timeout throwing UnsupportedMediaException in Java client?
I currently have a .net SOAP web service with a timeout in the request which I set with
Server.ScriptTimeout = TIME_OUT;
Then I have a java client calling the specified web service. However, when the timeout is reached, I get this exception:
Exception in thread "Thread-9" com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: text/html; charset=utf-8 Supported ones are: [text/xml]
What's going on is that the web service is returning a html error page with an http timeout code (503 I guess?) Which my Java code (generated using WSDLimport) was not expecting.
Now I could catch the UnsupportedMediaException error on the client and try to translate it into something more meaningful, but I would rather send a more specific timeout exception on the web service side. Is there anyway in the .net web service throwing a better exception when a timeout occurs or is there any other better way to handle this situation?
EDIT:
I am using WSDLImport from Glassfish 2 distribution.
source to share
This is a known issue with the Sun JAX-WS stack.
For reference, the HTTP code actually means that the server had an internal server error. I'm not sure why .NET is sending this and not HTTP 503 Service Unavailable.
source to share
You can make your webservice asynchronous . Then start a timer with a timeout in BeginMyMethod and throw a custom exception in your EndMyMethod method. It will be wrapped in a SOAP exception and sent to the client as such.
source to share