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; }
转载于:https://www.cnblogs.com/Elong/archive/2008/12/03/1346772.html
相关资源:java调用webservice几种方式