views:

2616

answers:

2

I currently have a .net SOAP web service with a timeout on the request that I set using

Server.ScriptTimeout = TIME_OUT;

I then have java client calling said 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 is happening is that the web service returns an html error page with the http timeout code (503 I think?), which my Java code (generated using WSDLimport) doesn't expect.

Now I could catch the error UnsupportedMediaException on the client and attempt to translate it into something more meaningful, but I would prefer to send out a more specific timeout exception on the web service side. Is there anyway in a .net web service to send out a better exception when a timeout occurs, or any other way to handle this situation better?

EDIT:
I am using the WSDLImport from the glassfish 2 distribution.

A: 

You can make your webservice asynchronous. Then start a timer with your timeout in the BeginMyMethod, and throw custom exception in your EndMyMethod method. It will be wrapped in SOAP exception and sent to the client as such.

Sunny
Couldn't I keep a timer in a synchronous web service? It seems strange that there no better built-in way to do this. I just assumed I was doing something wrong.
James McMahon
You can, but this is bad when you have long running operations. Every web request ocuupies one thread of the threadpool. If you don't make it async (for long operations), this thread is busy until the request is over.
Sunny
+1  A: 

This is a known issue with Sun's JAX-WS stack.

For reference, the HTTP 500 code actually means that the server had an Internal Server Error. I'm not sure why .NET sends that rather than HTTP 503 Service Unavailable.

R. Bemrose
I am not actually sure what error code it is sending, I just took a guess. It is probably a 503.Thanks for the info. I have been using glassfish for the WSDL import, but would using something like Apache Axis solve my problem?
James McMahon
Chances are using Axis would get around this, yes. Or it might add some new complexities... I haven't used Axis in a while, so I couldn't say.
R. Bemrose