开发者

How do I get the XML response after I receive an HTTP status different than OK?

The httpRequest.GetResponse() method gets a status code of 422 (Unprocessable entity) and throws an exception. In this webservice I am using, I know that an XML response is also sent and I need to get that response in order to find out why the server could not process my request.

How do I get the XML response in the 开发者_开发问答catch block?

try
{
    // Submits the HTTP request to create the invoice and gets the XML response.
    using (HttpWebResponse httpResponse = httpRequest.GetResponse() as HttpWebResponse)
    {
        // my code...
        return httpResponse;
    }
}
catch (Exception e)
{
}


Catch WebException and access e.Response property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜