To test the provision interfaceSystem. net. httpwebrequestClass sends the sample XML in the MISC system Short Message SP access guide-interface transformation sub-book to the Web service, and returns the corresponding resp package (also a piece of XML) from the web service ), next we willCodePost it:
1,SyncorderrelationreqXML content of the package:
Code
< SOAP-ENV: Envelope Xmlns: xsi = "Http://www.w3.org/2001/XMLSchema-instance" Xmlns: XSD = "Http://www.w3.org/2001/XMLSchema" Xmlns: SOAP-ENV = "Http://schemas.xmlsoap.org/soap/envelope" Xmlns: SOAP-ENC = "Http://schemas.xmlsoap.org/soap/encoding" >
< SOAP-ENV: Header >
< Transactionid Xmlns = "Http://www.monternet.com/dsmp/schemas" > 00110318384464 </ Transactionid >
</ SOAP-ENV: Header >
< SOAP-ENV: Body >
< Syncorderrelationreq Xmlns = "Http://www.monternet.com/dsmp/schemas" >
< Version > 1.5.0 </ Version >
< Msgtype > Syncorderrelationreq </ Msgtype >
< Send_address >
< Devicetype > 0 </ Devicetype >
< DeviceID > 0011 </ DeviceID >
</ Send_address >
< Dest_address >
< Devicetype > 400 </ Devicetype >
< DeviceID > 0 </ DeviceID >
</ Dest_address >
< Feeuser_id >
< Useridtype > 1 </ Useridtype >
< Msisdn > 13456781234 </ Msisdn >
< Pseudo Code > </ Pseudo Code >
</ Feeuser_id >
< Destuser_id >
< Useridtype > 1 </ Useridtype >
< Msisdn > 13456781234 </ Msisdn >
< Pseudo Code > </ Pseudo Code >
</ Destuser_id >
< Linkid > SP </ Linkid >
< Actionid > 1 </ Actionid >
< Actionreasonid > 1 </ Actionreasonid >
< Spid > 419000 </ Spid >
< Spserviceid > -Yyxxyyxx </ Spserviceid >
< Accessmode > 3 </ Accessmode >
< Featurestr > Mta2njixndqgree = </ Featurestr >
</ Syncorderrelationreq >
</ SOAP-ENV: Body >
</ SOAP-ENV: Envelope > 2, Httpwebrequest Code for calling the Web Service: Code
System. xml. xmldocument Doc = New Xmldocument ();
Doc. Load ( " C: // syncorderrelationreq. xml " );
Memorystream MS = New Memorystream ();
Doc. Save (MS );
System. net. httpwebrequest R=(System. net. httpwebrequest) system. net. webrequest. Create ("Http: // localhost/websrv/dsmp. asmx");
R. Method = " Post " ;
R. contenttype = @" Text/XML; charset = UTF-8 " ;
R. headers. Add ( " Soapaction " , " / "" + " Sim. syncorderrelation " + " / "" );
R. Credentials = System. net. credentialcache. defaultcredentials;
Byte[] Bytes=Ms. toarray ();
R. contentlength=Bytes. length;
Stream s=R. getrequeststream ();
S. Write (bytes,0, Bytes. Length );
S. Close ();
Streamreader SR = New Streamreader (R. getresponse (). getresponsestream ());
String retxml = Sr. readtoend ();
Sr. Close ();
Doc = New Xmldocument ();
Doc. loadxml (retxml );
Doc. Save ( " C: // syncorderrelationresp. xml " ); This is just a small example of using httpwebrequest to call the web service. You only need to save the above XML file as In the syncorderrelationreq. xml file, the results returned by the web service are saved inSyncorderrelationresp. xml.