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.Crea te(url);
HttpWebRequest httpRequest = (HttpWebRequest )webRequest;
httpRequest.Met hod = "POST";
httpRequest.Con tentType = "text/xml";
httpRequest.Hea ders.Add("SOAPA ction: x");
Stream sendStream= httpRequest.Get RequestStream() ;
//Add Soap Envelop to the Request
StreamWriter writer = new StreamWriter(se ndStream);
writer.Write(so apEnvelope);
writer.Close();
sendStream.Clos e();
sendStream.Disp ose();
//Send the Request
WebResponse response = null;
StreamReader reader = null;
try
{
//Get the response
response = httpRequest.Get Response();
}
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.Crea te(url);
HttpWebRequest httpRequest = (HttpWebRequest )webRequest;
httpRequest.Met hod = "POST";
httpRequest.Con tentType = "text/xml";
httpRequest.Hea ders.Add("SOAPA ction: x");
Stream sendStream= httpRequest.Get RequestStream() ;
//Add Soap Envelop to the Request
StreamWriter writer = new StreamWriter(se ndStream);
writer.Write(so apEnvelope);
writer.Close();
sendStream.Clos e();
sendStream.Disp ose();
//Send the Request
WebResponse response = null;
StreamReader reader = null;
try
{
//Get the response
response = httpRequest.Get Response();
}
catch (WebException webEx)
{
....
Thanks.