Several ways to call WebService:
Method One: Add a Web reference (simple/convenient limitation client is. NET)
Method Two: Post XML (highlighted in this article)
Method Three: Use the Microsoft MSXML2 component (as if it is not supported on window server2008)
Method Four: Add the form post to the server on the page
//Create HttpWebRequest instances, using WebRequest.CreateHttpWebRequest webRequest = (HttpWebRequest) webrequest.create ("Service Address");//Send RequestWebrequest.method ="POST";//CodingWebrequest.contenttype ="Text/xml";stringSoap ="<?xml version=\ "1.0\" encoding=\ "utf-8\"?>"; Soap+="<soap:envelope xmlns:xsi=\ "http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\ "http://www.w3.org/2001 /xmlschema\ "xmlns:soap=\" http://schemas.xmlsoap.org/soap/envelope/\ ">"; Soap+="<soap:Header>"; Soap+="<soapheader xmlns=\ "http://www.52taiqiu.com/\" >"; Soap+="<Login>"+ Txtuser.text +"</Login>"; Soap+="<Password>"+ Txtpwd.text +"</Password>"; Soap+="</SoapHeader>"; Soap+="</soap:Header>"; Soap+="<soap:Body>"; Soap+="<request xmlns=\ "http://www.52taiqiu.com/\" >"; Soap+="<requestxml><! [Cdata["+ Txtrequest.text +"]]></requestxml>"; Soap+="</Request>"; Soap+="</soap:Body>"; Soap+="</soap:Envelope>"; webrequest.headers["SOAPAction"] ="http://www.52taiqiu.com/Request";//character to Bytebyte[] bytes =Encoding.UTF8.GetBytes (SOAP); Stream writer=Webrequest.getrequeststream (); writer. Write (Bytes,0, Bytes. Length); writer. Flush (); writer. Close ();stringresult ="";//back to HttpWebResponseTry{HttpWebResponse Hwres= Webrequest.getresponse () asHttpWebResponse;if(Hwres.statuscode = =System.Net.HttpStatusCode.OK) {//whether to return successStream Rstream =Hwres.getresponsestream ();//Stream ReadStreamReader sr =NewStreamReader (Rstream, Encoding.UTF8); result=Sr. ReadToEnd (); Sr. Close (); Rstream.close ();}Else{result="Connection Error";}//Closehwres.close (); Txtresponse.text=result;}Catch(System.Net.WebException ex) {String responsefromserver= ex. Message.tostring () +" ";if(ex. Response! =NULL){using(WebResponse response =Ex. Response) {Stream data=Response. GetResponseStream ();using(StreamReader reader =NewStreamReader (data)) {Responsefromserver+=Reader. ReadToEnd ();}}} Txtresponse.text=Responsefromserver;}
"Reprint" C # HttpWebRequest send soap XML