1。第一中不用说了。使用vs.net提供的工具,生成代理类。

2。使用webrequest的方法。

 

public static XmlDocument XmlSendByHttp(string xmlString, string url, string SoapAction)
        {
            XmlDocument outxml 
= new XmlDocument();
            Stream oWriter 
= null;
            
bool bResult = true;
            
byte[] data = Encoding.UTF8.GetBytes(xmlString);
            HttpWebRequest myRequest 
= (HttpWebRequest)WebRequest.Create(url);

            myRequest.Method 
= "POST";
            myRequest.Headers.Add(
"SOAPAction", SoapAction);    
            myRequest.Headers.Add("ContentLength", data.Length.ToString());
            myRequest.ContentType 
= "text/xml; charset=utf-8";

            
try
            {
                oWriter 
= myRequest.GetRequestStream();
                oWriter.Write(data, 
0, data.Length);
                oWriter.Close();
            }
            
catch
            {
                oWriter.Close();
                bResult 
= false;
            }

            Stream oReader 
= null;
            
if (bResult)
            {
                
try
                {
                    HttpWebResponse oResponse 
= (HttpWebResponse)myRequest.GetResponse();
                    oReader 
= oResponse.GetResponseStream();
                    outxml.Load(oReader);
                    oReader.Close();
                }
                
catch
                {
                }
            }
            
return outxml;
        }

相关文章:

  • 2021-07-08
  • 2022-01-15
  • 2021-11-27
  • 2021-05-04
  • 2022-01-19
  • 2021-10-07
猜你喜欢
  • 2021-08-12
  • 2021-09-29
  • 2021-04-26
  • 2022-12-23
  • 2022-02-14
  • 2022-01-12
相关资源
相似解决方案