VB6 calls WebService and WCF

Source: Internet
Author: User

 

'Call WebService. Install soaptoolkit30.exe and reference Microsoft soap Type Library V3.0 in the project.

Sub callwebservice ()

Dim m_spclient as new soapclient30 'soapclient30 Object Instantiation

M_spclient.mssoapinit "http: // localhost/mciswebservice/vbtest. asmx? WSDL "'reference WebService

Msgbox m_spclient.helloworld 'calls the WebService Method

End sub

 

 

'Http calls to WCF

Sub callhttpwcfservice ()

Dim mexmonikerstring as string dim mexservicemoniker as object 'your 'mex service moniker example 'Then 'create a string for the service moniker specifying the address' to retrieve the service metadata from mamemonikerstring = "service: mexico address = 'HTTP: // localhost: 55242/service1.s VC/MEX '"mmonikerstring = mmonikerstring +", address = 'HTTP: // localhost: 55242/service1.svc' "mmonikerstring = mmonikerstring +", binding = require, bindingnamespace = 'HTTP: // tempuri.org/'"mexmonikerstring = mexmonikerstring +", contract = iservice1, contractnamespace = 'HTTP: // tempuri.org/' "'create the service moniker object set Signature = GetObject (mmormonikerstring) 'Call the service operations using the moniker object msgbox Mexico servicemoniker. sayhello ("China! ") Set mexservicemoniker = nothing

End sub

 

'Tcp call to WCF

Sub calltcpwcfservice ()

Dim mexmonikerstring as string

Dim mexservicemoniker as object

'Create a string for the service moniker specifying the address

'To retrieve the service metadata from

Mexico monikerstring = "service: Mexico address = 'HTTP: // 192.168.1.110: 12345/binding/MEX '"

Mexmonikerstring = mexmonikerstring + ", address = 'Net. TCP: // 192.168.1.110: 54321/binding/hello '"

Mexmonikerstring = mexmonikerstring + ", binding = 'nettcpbinding _ ihel', bindingnamespace = 'HTTP: // tempuri.org /'"

Mexmonikerstring = mexmonikerstring + ", contract = ihello, contractnamespace = 'HTTP: // tempuri.org /'"

'Create the service moniker object

Set mexservicemoniker = GetObject (mexmonikerstring)

'Call the service operations using the moniker object

Msgbox mexservicemoniker. sayhello ("China! ")

Set mexservicemoniker = nothing

End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.