How to post SOAP Request from .NET?

前端 未结 7 2016
暖寄归人
暖寄归人 2020-12-08 02:28

I have the SOAP request in an XML file. I want to post the request to the web service in .net How to implement?

7条回答
  •  鱼传尺愫
    2020-12-08 03:25

    var uri = new Uri("http://localhost/SOAP/SOAPSMS.asmx/add");
    
    var req = (HttpWebRequest) WebRequest.CreateDefault(uri); 
    req.ContentType = "text/xml; charset=utf-8"; 
    req.Method = "POST"; 
    req.Accept = "text/xml"; 
    req.Headers.Add("SOAPAction", "http://localhost/SOAP/SOAPSMS.asmx/add"); 
    
    var strSoapMessage = @"
    
      235
    "; 
    
    using (var stream = new StreamWriter(req.GetRequestStream(), Encoding.UTF8)) 
        stream.Write(strSoapMessage); 
    

提交回复
热议问题