Web Services technology allows you to share data and communications between the xenographed environments to achieve the consistency of information. We can use
The HTTP POST / GET protocol, the SOAP protocol calls Web Services.
First, use the SOAP protocol to call Web Services in VB6
First, use the .NET to release a simple web service.
Public Function GetString (Byval Str As String) AS STRING
Return "Hello World," & Str & "!"
END FUNCTION
The web service contains only a getString method for returns a string. When we call this Web Services, the SOAP message sent to the .asmx page is:
XML Version = "1.0" encoding = "UTF-8"?>
XMLns: XSD = "http://www.w3.org/2001/xmlschema" xmlns: soap = "http: // Schemas.xmlsoap.org/soap/envelope / "> getString> soap: body> soap: envelope> And the return of the SOAP is: XML Version = "1.0" encoding = "UTF-8"?> XMLns: XSD = "http://www.w3.org/2001/xmlschema" xmlns: soap = " http://schemas.xmlsoap.org/soap/envelope/>>> getStringResponse> soap: body> soap: envelope> In VB6, this simple web service can be used to use the XMLHTTP protocol to send .asmx page Send SOAP to achieve. In VB6, establish a simple engineering, the interface is as shown in the figure, we call this simply by clicking on Button. Single Web Services DIM STRXML AS STRING Dim Str As String Str = text2.text 'Define SOAP messages Strxml = " XML Version = '1.0' encoding = 'UTF-8'?> XMLns: xsd = 'http://www.w3.org/2001/xmlschema' XMLns: soap = 'http://schemas.xmlsoap.org/soap/envelop/'> STR> getString> soap: body> soap: envelope> 'Define an HTTP object, send a POST message to the server DIM H as msxml2.serverxmlhttp40 'Define an XML document object, convert your handwritten or accepted XML content to XML object DIM X as msxml2.domdocument40 'Initializing XML object SET X = new msxml2.domdocument40 'Convert handwritten SOAP strings to XML objects X.LoadXML strXml 'Initializing HTTP object Set h = new msxml2.serverxmlhttp40 'Send a POST message to the specified URL H.Open "Post", "http://localhost/testwebservice/service1.asmx", False H.SetRequestHeader "Content-Type", "Text / XML" H.send (strXML) While H.ReadyState <> 4 Wend 'Display the returned XML information Text1.text = H.RESPONSETEXT 'Resolution of the returned XML information and display the return value SET X = new msxml2.domdocument40 X.LoadXml text1.text Text1.text = x.childNodes (1) .text We entered "China" in TextBox, then click Button, so you can display "Hello World, China" in the next TEXTBOX. Show as shown: