C # Soap Web Service WSDL

I created stubs from a wsdl file in an asp.net web application. My question is, how do I add these function calls to the httpwebrequest? I got this far but don't know how to finish it and send the soap to the wire.

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();

    }

      

+3


source to share


1 answer


I'm not sure why you wouldn't use the client methods you created, but:



using (var response = (HttpWebResponse)webRequest.GetResponse())
{
   var reader = new StreamReader(response.GetResponseStream());
   var result = reader.ReadToEnd();
}

      

+1


source







All Articles