• VB6调用WebService、WCF


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

    Sub CallWebService()

    Dim m_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

     '当调用WCF 时候,要注意一些事项.由于WCF对外公布的都是接口,如果WCF里定义了多个接口,VB6.0如果没对全部实现的话是会报错的.我仲未知点解决...WCF定义返回的是Class类,VB6.0那接收时也会出错.

    Jason個邊抄過來的調用WCF

    VB6.0 Call WCF

    Sub CallWCFService_TypedContract()
      
      Dim strMonikerString As String
      Dim serviceMoniker As Object
      
      '---------------------------------------------------------------
      ' Typed Contract service moniker example
      '---------------------------------------------------------------
      ' Create a service moniker object using a strongly typed contract
      ' This references the address, a standard binding type and the
      ' locally registered COM-visible contract ID
      
      monikerString = "service:address='http://localhost/WCFServiceMoniker/Service1.svc'"
      monikerString = monikerString + ", binding=wsHttpBinding"
      monikerString = monikerString + ", contract={4FBDA94E-8B89-32EC-BC28-2A0A5E9B7C74}"
      
      ' Create the service moniker object
      Set serviceMoniker = GetObject(monikerString)
      
      ' Call the service operations using the moniker object
      MsgBox serviceMoniker.SayHello("I am LazyBee, My blog is http://lazybee.cnblogs.com/ ")
      
      Set serviceMoniker = Nothing
    End Sub

  • 相关阅读:
    Flutter 使用Navigator进行局部跳转页面
    Flutter “孔雀开屏”的动画效果
    ORA-04063: package body "DBSNMP.BSLN" has errors
    ORA-04063: package body "DBSNMP.BSLN_INTERNAL" has errors
    Oracle 11gR2 待定的统计信息(Pending Statistic)
    Oracle查询dba_extents视图很慢
    Oracle查询表空间使用率很慢
    Oracle收集对表收集统计信息导致全表扫描直接路径读?
    Oracle IO性能测试
    Oracle Online Patching报错"This is not a RAC setup. OPatch cannot determine the local node name"
  • 原文地址:https://www.cnblogs.com/guyuehuanhuan/p/1948140.html
Copyright © 2020-2023  润新知