views:

4998

answers:

8

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?

+1  A: 

The SOAP toolkit is arguably the best you could get. Trying to do the same thing without it would require considerable extra effort. You need to have quite serious reasons to do that.

The format of the SOAP messages is not really easy to read or write manually and a third-party library is highly advised.

Ilya Kochetov
+3  A: 

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.

Martin
+3  A: 

.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.

huseyint
+3  A: 

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
Darrel Miller
+2  A: 

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.

Kris Erickson
+1  A: 

The SOAP Moniker relies on the SOAP Client (subset of SOAP Toolkit) that shipped with XP. It isn't present in Vista, etc.

Bob
+2  A: 

Check out this article by Scott Swigart on the MSDN VB 6.0 Resource Center.

Calling Web Services from Visual Basic 6, the Easy Way

Rob Windsor
I was thrilled to find that article. Until I realized he's using VB.net with VB6. Kinda defeats the purpose. (If I could use VB.net for part of this I'd just do it all in VB.net). His conclusion says it all " Building this application with just Visual Basic 6 would have been really hard. ".
Clay Nichols
+1  A: 

I've had some measure of success so far using PocketSOAP to connect to the Salesforce API. I could not use the WSDL Wizard because it generates wrapper class filenames using the first 23 characters of the call names, and this results in duplicates. Nevertheless, PocketSOAP has been working well enough for me without the wizard, and it's much more straightforward than using XMLHTTP with DOMDocument.

I also looked into making a wrapper in .NET or using one of the "MS Office {MSO version} Web Services Toolkit" libraries, but there were significant deployment hassles with those options. PocketSOAP is a simple COM DLL, not dependent on some particular version of MS Office, and is licensed under MPL.

Steve Jorgensen