In many cases, Visual Basic 6 developers need to add web reference and its not that easy. Here is an example that how you can add web service reference(wsdl service). To run this example code you need to add reference of Microsoft Soap Type Library and Microsoft XML,
V3.0 to your project. As there are comments to explain everything so its easy to change according to your needs.
Use commands which your wsdl service provides. This example code is for to get Quotes from Marketiva Streamster WSDL service API( A forex company). Read here more about it.
' To package SOAP request.
Dim objSerial As MSSOAPLib.SoapSerializer
' To read SOAP response.
Dim objRead As MSSOAPLib.SoapReader
' To connect to Web service using SOAP.
Dim objConn As MSSOAPLib.SoapConnector
' To parse the SOAP response.
Dim objResults As MSXML2.IXMLDOMNodeList
Dim objNode As MSXML2.IXMLDOMNode
' Set up the SOAP connector.
Set objConn = New MSSOAPLib.HttpConnector
objConn.Property("EndPointURL") = "http://127.0.0.1:8018/endpoint"
' Define the SOAP action. You can find it in the WSDL's
' tag's soapAction attribute for the matching
' tag.
objConn.Property("SoapAction") = "GetQuote"
' Begin the SOAP message.
objConn.BeginMessage
Set objSerial = New MSSOAPLib.SoapSerializer
' Initialize the serializer to the connector's input stream.
objSerial.Init objConn.InputStream
' Build the SOAP message.
With objSerial
.startEnvelope '
.startBody '
.startElement "Instrument"
.writeString "EUR/USD"
.endElement ' input par
.endBody '
.endEnvelope '
End With
' Send the SOAP message.
objConn.EndMessage
Set objRead = New MSSOAPLib.SoapReader
' Initialize the SOAP reader to the connector's output stream.
objRead.Load objConn.OutputStream
Debug.Print objRead.DOM.xml
Set objResults = objRead.Body.childNodes
For Each objNode In objResults
Select Case objNode.nodeName
Case "Quote"
MsgBox objNode.selectSingleNode("Last").nodeTypedValue 'show Last price of quote
MsgBox objNode.selectSingleNode("Time").nodeTypedValue 'show Time of quote
Case Else
End Select
Next objNode
Searched By:
vb6 wsdl (13), MSSOAPLib (6), web reference visual basic 6 (3), powered by vBulletin reference (2), using web service vb6 marketiva (2), streamster c# sample (2), wsdl vb6 (2), streamster api indicator (1), vb6 api web reference (1), vb xml soap getquote (1), vb net soap xml wsdl mysql php (1), vb net 2010 service reference catch message (1), sopa vb6 response (1), vb dengan marketiva (1), vb 6 0 to read xml response from webservice (1), vb 6 0 read stream (1), vb 2010 post xml request (1), vb 2010 envelope (1), streamster api (1), using web references in vb6 (1)No related posts.
Doesn’t work, i’m using Microsoft Soap Type Library v3 and it freezes. Any suggestion?
i recommend using VB.NET 2008 it’s easy to add web service like Marketiva API