我如何从代码中的webservice请求和获取响应?

时间:2013-11-10 15:53:10

标签: c# asp.net soap wsdl

我是SOAP WSDL的新手,但到目前为止,我一直在尝试使用代码请求并从HTTP请求获取响应。这就是我试过的

        string result = string.Empty;

        HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create("http://thesite.com/WebService/iTopUp/reseller_itopup.server.php?wsdl");

        myRequest.Method = "POST";

        using (StreamWriter requestWriter = new StreamWriter(myRequest.GetRequestStream()))
        {

            requestWriter.Write("&{0}={1}", HttpUtility.UrlEncode("LoginId"), HttpUtility.UrlEncode("123456789"));

            requestWriter.Write("&{0}={1}", HttpUtility.UrlEncode("Message"), HttpUtility.UrlEncode("Ok"));

            requestWriter.Write("&{0}={1}", HttpUtility.UrlEncode("Checksum"), HttpUtility.UrlEncode("5ad972a49817c1ab98fe67e"));


        }
        using (StreamReader responseReader = new StreamReader(myRequest.GetResponse().GetResponseStream()))
        {

            result = responseReader.ReadToEnd();

        }
        TextBox1.Text = result;

但这是我收到的错误

     Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

     Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

      Source Error:


      Line 53:                
     Line 54:             }
   Line 55:             using (StreamReader responseReader = new             StreamReader(myRequest.GetResponse().GetResponseStream()))
    Line 56:             {
    Line 57: 

我做得不对吗?

0 个答案:

没有答案
相关问题