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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dav

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

    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

  • Mr. Arnold

    #2
    Re: Csharp .NET - VS2003 - console application - Webservice request and sending SOAP body


    "Dav" wrote in message news:2008527162 320drvac@coolto ad.com...
    >I used soapUI (webservice testing tool) to test thrird party secure
    >ondemand webservice and worked fine and communicating from our proxy. they
    >authenticate d 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.
    -------

    Is there not a more detailed explanation of the error in the application or
    system event log on the machine?

    Comment

    • Dav V

      #3
      Csharp .NET - VS2003 - console application - Webservicereque st and sending SOAP body - Mr. Arnold

      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

      Comment

      Working...