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