Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to consume a web service from VB6?

I need to consume an external web service from my VB6 program. I want to be able to deploy my program without the SOAP toolkit, if possible, but that's not a requirement. I do not have the web service source and I didn't create it. It is a vendor-provided service.

So outside of the SOAP toolkit, what is the best way to consume a web service from VB6?

like image 311
Robert S. Avatar asked Sep 23 '08 17:09

Robert S.


4 Answers

I use this function to get data from a web service.

Private Function HttpGetRequest(url As String) As DOMDocument
    Dim req As XMLHTTP60
    Set req = New XMLHTTP60
    req.Open "GET", url, False
    req.send ""

    Dim resp As DOMDocument
    If req.responseText <> vbNullString Then
        Set resp = New DOMDocument60
        resp.loadXML req.responseText
    Else
        Set resp = req.responseXML
    End If
    Set HttpGetRequest = resp
End Function
like image 198
Darrel Miller Avatar answered Nov 16 '22 12:11

Darrel Miller


.NET has a good support for Web Services since day one, so you can develop your Web Service client logic in .NET as a .dll library/assembly and use it in VB6 app via COM Interop.

like image 20
huseyint Avatar answered Nov 16 '22 11:11

huseyint


Assuming that you're running on Windows XP Professional or above, one interesting method is to use the SOAP moniker. Here's an example, lifted from some MSDN page. I don't know if this particular service works, but you get the idea...

   set SoapObj = GetObject
       ("soap:wsdl=http://www.xmethods.net/sd/TemperatureService.wsdl")
   WScript.Echo "Fairbanks Temperature = " & SoapObj.getTemp("99707")

This mechanism also works from VBScript. Which is nice.

like image 3
Martin Avatar answered Nov 16 '22 11:11

Martin


Pocketsoap works very well. To generate your objects use the WSDL generator. Using this you don't have to parse anything yourself, plus everything is nice and strongly typed.

like image 2
Kris Erickson Avatar answered Nov 16 '22 12:11

Kris Erickson