简体   繁体   中英

How to call WCF service and set its configuration using 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

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

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.

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.

See " Communicate with WCF Windows Service in VB6? ".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM