A
Alpha83
Calling a webservice using HttpWebRequest below. Only WebException
can be caught per documentation. How about SoapException - how do I
get those details. Most web services will throw soapexceptions. Any
way to accomplish this.
public HttpWebResponse SendSoapRequest(string soapEnvelope, string
url)
{
//Setup the Request
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest httpRequest = (HttpWebRequest)webRequest;
httpRequest.Method = "POST";
httpRequest.ContentType = "text/xml";
httpRequest.Headers.Add("SOAPAction: x");
Stream sendStream= httpRequest.GetRequestStream();
//Add Soap Envelop to the Request
StreamWriter writer = new StreamWriter(sendStream);
writer.Write(soapEnvelope);
writer.Close();
sendStream.Close();
sendStream.Dispose();
//Send the Request
WebResponse response = null;
StreamReader reader = null;
try
{
//Get the response
response = httpRequest.GetResponse();
}
catch (WebException webEx)
{
....
Thanks.
can be caught per documentation. How about SoapException - how do I
get those details. Most web services will throw soapexceptions. Any
way to accomplish this.
public HttpWebResponse SendSoapRequest(string soapEnvelope, string
url)
{
//Setup the Request
WebRequest webRequest = WebRequest.Create(url);
HttpWebRequest httpRequest = (HttpWebRequest)webRequest;
httpRequest.Method = "POST";
httpRequest.ContentType = "text/xml";
httpRequest.Headers.Add("SOAPAction: x");
Stream sendStream= httpRequest.GetRequestStream();
//Add Soap Envelop to the Request
StreamWriter writer = new StreamWriter(sendStream);
writer.Write(soapEnvelope);
writer.Close();
sendStream.Close();
sendStream.Dispose();
//Send the Request
WebResponse response = null;
StreamReader reader = null;
try
{
//Get the response
response = httpRequest.GetResponse();
}
catch (WebException webEx)
{
....
Thanks.