none
calling a WCF server methods dynamically by a WCF Test Client RRS feed

  • Question

  • Hi,

                I am developing a wcf Test client which test the web services dynamically. As part of this I Am facing a problem with response from the server while calling a method dynamically I am getting Page not found error.

     

    My code is

     

                 string oRequest = @"<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"">

      <s:Header>

        <Action s:mustUnderstand=""1"" xmlns=""http://schemas.microsoft.com/ws/2005/05/addressing/none"">http://tempuri.org/IICalc/Add</Action>

      </s:Header>

      <s:Body>

        <Add xmlns=""http://tempuri.org/"">

          <x>0</x>

          <y>0</y>

        </Add>

      </s:Body>

    </s:Envelope>";

                    //Builds the connection to the WebService.

                    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://localhost:8733/Design_Time_Addresses/Mathematics/IICalc/?wsdl");

                    req.Headers.Add("SOAPAction", @"http://tempuri.org/IICalc/Add");

                    req.ContentType = "text/xml; charset=\"utf-8\"";

                    req.Accept = "text/xml";

                    req.Method = "POST";

                    //Passes the SoapRequest String to the WebService

                    using (Stream stm = req.GetRequestStream())

                    {

                        using (StreamWriter stmw = new StreamWriter(stm))

                        {

                            stmw.Write(oRequest);

                        }

                    }

                    //Gets the response

                    //WebResponse response = req.GetResponse();

       HttpWebResponse response = (HttpWebResponse)req.GetResponse();  // getting error at //this point

                    //Writes the Response

                    Stream responseStream = response.GetResponseStream();

                    MessageBox.Show(responseStream.ToString());

    Please let me know where I am going wrong.

    Is there any other way to call the server methods other than http, Channel factory ???

    If there are any other optimal way to achieve the same  please share with me.

    Thank you.

     

    MANIKANTA




    • Edited by Manikanta3 Wednesday, June 12, 2013 1:13 PM
    Wednesday, June 12, 2013 11:59 AM

Answers

All replies