加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

VB6调用WebService、WCF

发布时间:2020-12-16 22:17:53 所属栏目:大数据 来源:网络整理
导读:'调用webservice。需要安装SoapToolkit30.EXE,并在工程中引用Microsoft Soap Type Library v3.0 Sub CallWebService() Dimm_spClient As New SoapClient30 'SoapClient30对象实例化 m_spClient.MSSoapInit "http://localhost/MCISWebService/vbtest.asmx?WSD

'调用webservice。需要安装SoapToolkit30.EXE,并在工程中引用Microsoft Soap Type Library v3.0

Sub CallWebService()

Dimm_spClient As New SoapClient30 'SoapClient30对象实例化

m_spClient.MSSoapInit "http://localhost/MCISWebService/vbtest.asmx?WSDL" '引用webservice

MsgBox m_spClient.HelloWorld '调用webservice方法

End Sub

'http方式调用WCF

Sub CallHTTPWCFService()

Dim mexMonikerString As String
Dim mexServiceMoniker As Object
'---------------------------------------------------------------
' MEX service moniker example
'---------------------------------------------------------------
' Create a string for the service moniker specifying the address
' to retrieve the service metadata from
mexMonikerString = "service:mexAddress='http://localhost:55242/Service1.svc/mex'"
mexMonikerString = mexMonikerString + ",address='http://localhost:55242/Service1.svc'"
mexMonikerString = mexMonikerString + ",binding=WSHttpBinding_IService1,bindingNamespace='http://tempuri.org/'"
mexMonikerString = mexMonikerString + ",contract=IService1,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

'TCP方式调用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

mexMonikerString = "service:mexAddress='http://192.168.1.110:12345/Binding/mex'"

mexMonikerString = mexMonikerString + ",address='net.tcp://192.168.1.110:54321/Binding/Hello'"

mexMonikerString = mexMonikerString + ",binding='NetTcpBinding_IHello',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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读