Code :
'Write text to the specified file and specify whether the function z_writefile (sfilename, stext, bappend) dim FS, FSO, iomode if bappend = true then iomode = 8' forappending else iomode = 2' forwriting end if set FS = Createobject ("scripting. fileSystemObject ") set FSO = FS. opentextfile (sfilename, iomode, true) 'The third parameter indicates that the file does not exist, and the new file FSO is created. writeline stext FSO. close set FSO = nothing set FS = nothing z_writefile = trueend functiondim objhttp, xmldoc, stext, sxmlset objhttp = Createobject ("msxml2.xmlhttp") set xmldoc = Createobject ("MSXML. domdocument ") strwebserviceurl =" http: // 192.168.2.39/webservice1/service. asmx/addition "strrequest =" I = 2 & J = 3 "objhttp. open "Post", strwebserviceurl, falseobjhttp. setRequestHeader "Content-Type", "application/X-WWW-form-urlencoded" objhttp. send (strrequest) If objhttp. status = 200 then dim snodelist, sresult xmldoc. load (objhttp. responsexml) set snodelist = xmldoc. getelementsbytagname ("double") sresult = snodelist (0 ). text stext = "2 + 3 =" & sresultelse stext = "WebService call error. Please check" End ifz_writefile "resultvoice.txt", stext, false
WebService is developed by vs. net2010 (C #). The core code is as follows:
Using system; using system. web; using system. web. services; using system. web. services. protocols; [WebService (namespace = "http://tempuri.org/")] [webservicebinding (conformsto = wsiprofiles. basicprofile1_1)] public class service: system. web. services. webService {Public Service () {// If the designed component is used, uncomment the following line // initializecomponent ();} [webmethod (description = "let's say \" Hello \ "")] Public String HI () {return" Hello world, Happy New Year ";} [webmethod (description =" Hello joeblack ")] Public String Hello (string username) {return username +", Happy New Year ";} [webmethod (description = "summation method")] public double addition (double I, Double J) {return I + J ;} [webmethod (description = "")] public double subtract (double I, Double J) {return I-j ;} [webmethod (description = "Method for product calculation")] public double Mult Iply (double I, Double J) {return I * j;} [webmethod (description = "method of quotient")] public double division (double I, Double J) {If (J! = 0) return I/J; else return 0 ;}}
To enable WebService support for httpget and httppost protocols (the default configuration only supports the SOAP protocol), you must add the following content to the Web. config of the WebService project:
<System. Web> <! -- Set compilation DEBUG = "true" to insert debugging symbols into compiled pages. However, this affects performance. Therefore, set this value to true only during development. --> <Compilation DEBUG = "true" targetframework = "4.0"> </compilation> <! -- The Security Authentication mode can be configured in the <authentication> section. ASP. NET uses this mode to identify the visitor. --> <! -- Configure WebService to support httppost and httpget protocols --> <WebServices> <protocols> <Add name = "httppost"/> <Add name = "httpget"/> </protocols> </ webServices> <Authentication mode = "Windows"/>
The result is written to the resultvoice.txt file.