从VB6使用Web服务的最佳方法是什么?

时间:2022-04-11 20:22:54

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.

我需要从VB6程序中使用外部Web服务。如果可能的话,我希望能够在没有SOAP工具包的情况下部署我的程序,但这不是必需的。我没有Web服务源,也没有创建它。它是供应商提供的服务。

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

因此,在SOAP工具包之外,从VB6使用Web服务的最佳方法是什么?

7 个解决方案

#1


8  

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

我使用此函数从Web服务获取数据。

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

#2


4  

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

从第一天开始,.NET就对Web服务提供了很好的支持,因此您可以将.NET中的Web服务客户端逻辑作为.dll库/程序集开发,并通过COM Interop在VB6应用程序中使用它。

#3


3  

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

假设您在Windows XP Professional或更高版本上运行,一种有趣的方法是使用SOAP名字对象。这是一个例子,取自某些MSDN页面。我不知道这项服务是否有效,但你明白了......

   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.

这种机制也适用于VBScript。这很好。

#4


2  

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.

Pocketsoap运行良好。要生成对象,请使用WSDL生成器。使用它你不必自己解析任何东西,加上一切都很好并且强类型。

#5


1  

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

在MSDN VB 6.0资源中心查看Scott Swigart撰写的这篇文章。

Calling Web Services from Visual Basic 6, the Easy Way

从Visual Basic 6调用Web服务,简单方法

#6


1  

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.

到目前为止,我已经使用PocketSOAP连接到Salesforce API取得了一些成功。我无法使用WSDL向导,因为它使用调用名称的前23个字符生成包装类文件名,这会导致重复。尽管如此,PocketSOAP在没有向导的情况下对我来说已经足够好了,而且比使用带有DOMDocument的XMLHTTP要简单得多。

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.

我还研究了在.NET中创建包装器或使用“MS Office {MSO版本} Web服务工具包”库之一,但是这些选项存在重大的部署麻烦。 PocketSOAP是一个简单的COM DLL,不依赖于某些特定版本的MS Office,并且是根据MPL许可的。

#7


0  

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.

SOAP工具包可以说是你能得到的最好的工具包。试图在没有它的情况下做同样的事情需要相当多的额外努力。你需要有相当严重的理由这样做。

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

SOAP消息的格式不容易手动读取或写入,强烈建议使用第三方库。

#1


8  

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

我使用此函数从Web服务获取数据。

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

#2


4  

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

从第一天开始,.NET就对Web服务提供了很好的支持,因此您可以将.NET中的Web服务客户端逻辑作为.dll库/程序集开发,并通过COM Interop在VB6应用程序中使用它。

#3


3  

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

假设您在Windows XP Professional或更高版本上运行,一种有趣的方法是使用SOAP名字对象。这是一个例子,取自某些MSDN页面。我不知道这项服务是否有效,但你明白了......

   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.

这种机制也适用于VBScript。这很好。

#4


2  

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.

Pocketsoap运行良好。要生成对象,请使用WSDL生成器。使用它你不必自己解析任何东西,加上一切都很好并且强类型。

#5


1  

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

在MSDN VB 6.0资源中心查看Scott Swigart撰写的这篇文章。

Calling Web Services from Visual Basic 6, the Easy Way

从Visual Basic 6调用Web服务,简单方法

#6


1  

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.

到目前为止,我已经使用PocketSOAP连接到Salesforce API取得了一些成功。我无法使用WSDL向导,因为它使用调用名称的前23个字符生成包装类文件名,这会导致重复。尽管如此,PocketSOAP在没有向导的情况下对我来说已经足够好了,而且比使用带有DOMDocument的XMLHTTP要简单得多。

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.

我还研究了在.NET中创建包装器或使用“MS Office {MSO版本} Web服务工具包”库之一,但是这些选项存在重大的部署麻烦。 PocketSOAP是一个简单的COM DLL,不依赖于某些特定版本的MS Office,并且是根据MPL许可的。

#7


0  

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.

SOAP工具包可以说是你能得到的最好的工具包。试图在没有它的情况下做同样的事情需要相当多的额外努力。你需要有相当严重的理由这样做。

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

SOAP消息的格式不容易手动读取或写入,强烈建议使用第三方库。