I used soapUI (webservice testing tool) to test thrird party secure ondemand webservice and worked fine and communicating from our proxy. they authenticated our proxy port . but when i deploy .NET console C# client to test, I am not getting response and throwing Internal exception error 500. don't know what i am missing in the following code and looks to me everything is fine.
Note: basic authentication is not required, bcos they onfigured our proxy.
Any help would be great and I really appreciate that. Thanks.
namespace SampleSoapClien t
{
class SampleCall
{
[STAThread]
public static void Main(string[] args)
{
HttpWebRequest req =
(HttpWebRequest )WebRequest.Cre ate("https://");
System.Net.WebP roxy myProxy = new System.Net.WebP roxy("my-proxy:80",false );
req.Proxy = myProxy;
string soapRequestStr;
soaprequest = " SOAP BODY";
string errMsg;
req.Method = "POST";
req.ContentType = "text/xml";
req.ContentLeng th = soaprequest.Len gth;
//req.Accept = "text/xml";
// REQUEST IS FIND AND NOT THROWING ANY EXCEPTION
try
{
Stream myStream = req.GetRequestS tream();
StreamWriter sWriter = new StreamWriter(my Stream);
sWriter.Write(s oapRequestStr);
sWriter.Close() ;
}
catch(Exception exp)
{
errMsg = "Stream writer object error : " + exp.Message;
Console.WriteLi ne(errMsg);
}
// RESPONSE IS THROWING EXCEPTION. Internal Web exception error 500
WebResponse resp = null;
StreamReader sReader = null;
string result;
try
{
HttpWebResponse resp = (HttpWebRespons e) req.GetResponse ();
resp = req.GetResponse ();
Stream respStream = resp.GetRespons eStream();
sReader = new StreamReader(re spStream);
result = sReader.ReadToE nd();
}
catch(Exception ex)
{
errMsg = "Response error : " + ex.Message;
Console.WriteLi ne(errMsg);
}
} // main
} // class SampleCall
} // namespace
Note: basic authentication is not required, bcos they onfigured our proxy.
Any help would be great and I really appreciate that. Thanks.
namespace SampleSoapClien t
{
class SampleCall
{
[STAThread]
public static void Main(string[] args)
{
HttpWebRequest req =
(HttpWebRequest )WebRequest.Cre ate("https://");
System.Net.WebP roxy myProxy = new System.Net.WebP roxy("my-proxy:80",false );
req.Proxy = myProxy;
string soapRequestStr;
soaprequest = " SOAP BODY";
string errMsg;
req.Method = "POST";
req.ContentType = "text/xml";
req.ContentLeng th = soaprequest.Len gth;
//req.Accept = "text/xml";
// REQUEST IS FIND AND NOT THROWING ANY EXCEPTION
try
{
Stream myStream = req.GetRequestS tream();
StreamWriter sWriter = new StreamWriter(my Stream);
sWriter.Write(s oapRequestStr);
sWriter.Close() ;
}
catch(Exception exp)
{
errMsg = "Stream writer object error : " + exp.Message;
Console.WriteLi ne(errMsg);
}
// RESPONSE IS THROWING EXCEPTION. Internal Web exception error 500
WebResponse resp = null;
StreamReader sReader = null;
string result;
try
{
HttpWebResponse resp = (HttpWebRespons e) req.GetResponse ();
resp = req.GetResponse ();
Stream respStream = resp.GetRespons eStream();
sReader = new StreamReader(re spStream);
result = sReader.ReadToE nd();
}
catch(Exception ex)
{
errMsg = "Response error : " + ex.Message;
Console.WriteLi ne(errMsg);
}
} // main
} // class SampleCall
} // namespace
Comment