0

I have C# .Net 2.0 App that is client of SOAP web services added to project through WebReferences. .Net creates convenient wrapper classes extending SoapHttpClientProtocol, so that everything like XML and serialization/deserialization of SOAP XML request/response in the communication is hidden.

I need to log the request and response to the WebServices and especially I want to have the HTTP status codes from the response the HTTP communication.

So far I have implemented SOAP Extension and to get the raw SOAP XML Requests/Responses, however I am unable to get the HTTP status code of the HTTP SOAP Response of the communication?


EDIT: So what I have is an instance of SoapHttpClientProtocol (generated by WSDL) and I want to get the HTTP status code from the communication.

I decompiled

private object[] ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, bool asyncCall)

Curiously there is this condition in it, which actually does not throw error when status 500?

if (num1 >= 300 && num1 != 500 && num1 != 400)
{
    throw new WebException(RequestResponseUtils.CreateResponseExceptionString(httpWebResponse, responseStream), null, WebExceptionStatus.ProtocolError, httpWebResponse);
}

EDIT2: So my problem generally is that I have response with HTTP status 500, which actually passes as success, without throwing WebException, due to the code above, which does not work for me, I want to detect such situation, that is why I need the HTTP status code.

HTTP/1.1 500 Internal Server Error
Lyubo Gos
  • 19
  • 6

1 Answers1

0

If you want the Http wrapper of the request/response, you can try something like this Call web APIs in C# using .NET framework 3.5.

Community
  • 1
  • 1
eyal
  • 369
  • 1
  • 5
  • 14
  • Thanks for you answer. I am using .NET 2.0, this is legacy system. And I do not want to go for HttpWebRequest/Response classes (in fact I switched from them to web references, which gives me this limitation that now I cannot have the HTTP status code) and to compose/generate the XML myself. I ask if there is possible way to do this either from the SOAP extension, or I should write similar to *soap extension* for HTTP apporach? – Lyubo Gos Oct 22 '15 at 13:03