views:

295

answers:

1

Hi,

I've a simple question, for you, that I just can't seem to get my head around.

The situation is the following:

  • We create and send a request to a web service, using WSE 3.
  • The web service is written in Java.

Most of the things are fine, but I can't seem to have an impact on the ContentType of either the WebResuest or WebResponse and that's causing some problems.

The errormessage I keep getting is the following:

Client found a response content type of ' application/xop+xml;type="text/xml; charset=utf-8" ' but expected 'text/xml'. The request failed with the error message: ....

In the details of the error message it has the response to our call from the server and it's coming through properly. Obviously it's not good as it is at the moment as it's coming through an exception :).

So, how could I set the expected content type for the response?

If I'm correct, the Request and the Response in WSE 3.0 has to have the same ContentType. So I thought I would try to set the request.Headers[HttpRequestHeader.ContentType] to the expected one, but with no luck. (also, I can set the HttpWebRequest's contenttype in quite a few places, but none of them seem to do the trick)

+1  A: 

This has been solved luckily, so here's the solution for future reference:

Our client inherits from the WebServicesClientProtocol class, in which there's a method called GetWebResponse(..). Simply overriding that method and changing the ContentType of the Response seemed to work out for us.

    protected override WebResponse GetWebResponse(System.Net.WebRequest request)
    {
        WebResponse response = base.GetWebResponse(request);
        response.Headers[HttpResponseHeader.ContentType] = "text/xml";
        return response;
    }
snomag