SoFunction
Updated on 2025-03-07

C# Soap instance calling WebService

Examples are as follows:

public class WebServiceHelper
 {
  /// <summary>
  ///Soap protocol Post method  /// </summary>
  /// <param name="uri">WebService Address</param>  /// <param name="str">Passing in Soap protocol format data</param>  /// &lt;returns&gt;&lt;/returns&gt;
  public static string SendToReturn(Uri _uri, string _str)
  {
   string _returnstr = "";
   //Stamp request   WebRequest webRequest = (_uri);
    = "text/xml; charset=utf-8";
    = "POST";
   using (Stream requestStream = ())
   {
    byte[] paramBytes = Encoding.(_str);
    (paramBytes, 0, );
   }
   //response   try
   {
    WebResponse webResponse = ();
    using (StreamReader myStreamReader = new StreamReader((), Encoding.UTF8))
    {
     _returnstr = ();
    }
   }
   catch (WebException ex)
   {
    _returnstr = new StreamReader(()).ReadToEnd();
   }
   return _returnstr;
  }
 }

The above example of C# Soap calling WebService is all the content I share with you. I hope you can give you a reference and I hope you can support me more.