如何使用VB6调用WCF服务并设置其配置 [英] How to call WCF service and set its configuration using VB6

查看:27
本文介绍了如何使用VB6调用WCF服务并设置其配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经浏览了一些主题,并且能够使用以下代码在 vb6 中调用服务:

I have gone through some topics and was able to call a service in vb6 by using the following code:

Dim sUrl As String
Dim response As String
Dim xmlHttp

Private Sub Form_Load()
sUrl = "http://abc.com/services/abc.svc"


Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlHttp.Open "POST", sUrl, False

xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlHttp.send
Dim response As String
response = xmlHttp.responseText

Set xmlHttp = Nothing


End Sub

问题是如何在 vb6 中调用 WCF 服务并将参数传递给其方法并获得结果?

The question is how do i call a WCF service in vb6 and pass params to its methods and get the results?

推荐答案

如果您尝试这种方式,则必须手动构建请求 XML,发送它,然后再次手动解析响应 XML.

If you try it this way, you'll have to build the request XML by hand, send it, then parse the response XML, again, by hand.

执行此操作的更好方法是在 VB.NET 或 C# 中创建 WCF 客户端,然后将客户端公开为 COM 对象.您的 VB6 代码将能够像对待任何其他 COM 对象一样对待它,因此它根本不必使用 XML.

The better way to do this is to create a WCF Client in VB.NET or C#, then expose the client as a COM object. Your VB6 code will be able to treat it exactly like any other COM object, so it won't have to play with XML at all.

请参阅在 VB6 中与 WCF Windows 服务通信?".

这篇关于如何使用VB6调用WCF服务并设置其配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆