This article focuses on the issue of WebServices intentionally redirecting requests to other locations. Please first make sure that the exception is not caused unintentionally, for example by incorrect authorization policy in web.config.
In general, Web Browsers handle redirects with no issues. If "302 Object moved" is sent to indicate a redirect, the web browser happily checks new location and retrieves the data.
However, while web browsers automatically handle redirects regarding requests to WebServices, it seems that client proxy classes do not automatically handle such redirects. This is quite annoying - my WebBrowser automatically redirects 302s, the HttpWebRequest also does but the WebService proxy inheriting from SoapHttpClientProtocol does not!
I am not going to answer a general question "why do you need to redirect a web service call". I just assume you need, just as I do.
My first attempt to find the solution was to use Google. I've came upon nice article by Matt Powell, Using ASP.NET Session State in a Web Service (look for the "Cookieless Sessions" section).
In short, Matt's solution is to wrap each invocation in a try-catch clause which tries to remap original WebService's Uri to the new one. This solves the issue, however is not practical since you'd end up with wrapping each single WebService method with a bloating try-catch clause.
The nice thing in Matt's approach is that it's general - if any subsequent WebService call causes 302 to be sent to the client, it is handled on the client side.
Specific solution - single redirect
The case of my application is not as general as to require the remapping to be handled for every request. I need to remap the url just once during the first call, however an additional cookie is appended to this first request. Instead of wrapping each single method, I've just wrote a simple proxy class which inherit from the SoapHttpClientProtocol class.
As you can see, the first request is handled in a special way: a new request is made to the application server and if the response code is 302 the Url of the proxy class is remapped to the new location returned by the appliaction server.
What I then need to do is to move my client proxy classes in the class hierarchy from SoapHttpClientProtocol to SoapHttpClientProtocol302.