Csharp .NET - VS2003 - console application - Webservicerequest and sending SOAP body

  • Thread starter Thread starter Dav
  • Start date Start date
D

Dav

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 SampleSoapClient
{

class SampleCall
{

[STAThread]
public static void Main(string[] args)
{

HttpWebRequest req =

(HttpWebRequest)WebRequest.Create("https://");
System.Net.WebProxy myProxy = new System.Net.WebProxy("my-proxy:80",false);
req.Proxy = myProxy;

string soapRequestStr;
soaprequest = " SOAP BODY";
string errMsg;

req.Method = "POST";
req.ContentType = "text/xml";
req.ContentLength = soaprequest.Length;
//req.Accept = "text/xml";


// REQUEST IS FIND AND NOT THROWING ANY EXCEPTION
try
{


Stream myStream = req.GetRequestStream();
StreamWriter sWriter = new StreamWriter(myStream);
sWriter.Write(soapRequestStr);
sWriter.Close();

}
catch(Exception exp)
{
errMsg = "Stream writer object error : " + exp.Message;
Console.WriteLine(errMsg);
}

// RESPONSE IS THROWING EXCEPTION. Internal Web exception error 500

WebResponse resp = null;
StreamReader sReader = null;
string result;


try
{
HttpWebResponse resp = (HttpWebResponse) req.GetResponse();
resp = req.GetResponse();
Stream respStream = resp.GetResponseStream();
sReader = new StreamReader(respStream);
result = sReader.ReadToEnd();
}
catch(Exception ex)
{
errMsg = "Response error : " + ex.Message;
Console.WriteLine(errMsg);
}

} // main
} // class SampleCall
} // namespace
 
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.
 
It just throwing me out as soon as the web response object called. the error was
"The remote server returned an error (500) Internal Server Error"
status Protocol error
 
Back
Top