Although it is a very old technology, but when it comes to it, let's talk about it .....
Office EXCEL uses VBA to call WebService in two ways:
1. N years ago, Microsoft provided the mssoap30 component and compiled it for VC ++.. Net calls WebService in a similar way. They all add references, but the fatal defect is that 64-bit office is not supported.Program(Supports 32-bit office running on 64-bit machines), and Microsoft has explicitly reminded developers that it has abandoned mssoap30 and replaced it with office development of the framework.
This cannot be achieved ....
2. the basic HTTP method is used. This method is very good. Theoretically, any URL can be called to accept responsebody. It perfectly supports the WSDL and restful WebService. the Ajax call method must be enabled for the WSDL WebService developed by. net.
Function Getwsrrrlt (xmlstr As String ) As String Dim Objhttp, xmldoc ' Call WebService Method Set Objhttp = Createobject ( " Msxml2.xmlhttp " ) Set Xmldoc = Createobject ( " MSXML. domdocument " ) Strwebserviceurl = " Http: // 192.168.0.114/wsrr. asmx/callbyxml " Objhttp. Open " Post " , Strwebserviceurl, False'Post method is used by default. Objhttp. setRequestHeader " Content-Type " , " Application/JSON " Objhttp. Send ( " {Xmlinput :' " & Xmlstr & " '} " )'Xmlinput is a ws parameter.Getwsrrrlt = CSTR (Bytestobstr (objhttp. responsebody ), " UTF-8 " ) Getwsrrrlt =Getstringbyjson (getwsrrrlt)'. Net3.5 ,. for net4.0 and later WS, The JSON character format returned by default is {"D": "Here is the expected JSON, for example {" result ":" 1 "}"} ' Parse JSON format ' Dim objsc, strjson, objjs ' Strjosn = "{" "myname" ":" "liucqa" "," "myid" ":" 007 ""}" ' Set objsc = Createobject ("msscriptcontrol. scriptcontrol") 'calls the scriptcontrol object ' Strjson = "Var o =" & strjosn &";" ' Objsc. Language = "JavaScript" ' Objsc. addcode (strjson) ' Set objjs = objsc. codeobject. o ' Msgbox callbyname (objjs, "myname", vbget) & "=" & callbyname (objjs, "myid", vbget) ' Dim soapclient as soapclient30 ' Set soapclient = Createobject ("mssoap. soapclient30 ") ' Soapclient. mssoapinit "http: // 192.168.0.114/wsrr. asmx? WSDL "," wsrr "," wsrrsoap ","" ' Soapclient. clientproperty ("serverhttprequest") = true ' Getwsrrrlt = CSTR (soapclient. callbyxml (xmlstr )) End Function