4

我已经从 asp.net Web 应用程序中的 wsdl 文件生成了存根。我的问题是如何将这些函数调用添加到 httpwebrequest?我已经做到了这一点,但不知道如何完成它并将肥皂放在电线上。

public HttpWebRequest CreateWebRequest(string webMethod)
{
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("");
        webRequest.Headers.Add(@"SOAPAction", "\"http://www.multispeak.org/Version_3.0/"+ webMethod +"\"");
        webRequest.ContentType = "text/xml;charset=\"utf-8\"";
        webRequest.Accept = "text/xml";
        webRequest.Method = "POST";
        return webRequest;
}


protected void Button1_Click(object sender, EventArgs e)
    {
        MR_ServerSoapClient soapClient = new MR_ServerSoapClient(endPoint,uri);
        PingURLRequest request = new PingURLRequest();
        PingURLResponse response = new PingURLResponse();

    }
4

1 回答 1

1

我不确定您为什么不使用为您生成的客户端方法,但是:

using (var response = (HttpWebResponse)webRequest.GetResponse())
{
   var reader = new StreamReader(response.GetResponseStream());
   var result = reader.ReadToEnd();
}
于 2013-02-01T15:17:17.323 回答