VB6调用WebService、WCF vb6调用jar插件

   2023-02-09 学习力0
核心提示:'调用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?WSD
'调用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

 
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • Windows API Reference for C#, VB.NET
    不错的.net 下用API的参考站点地址在:http://www.webtropy.com/articles/Win32-API-DllImport-art9.asp 下面摘抄分类,便于大家直接就拿来用: File, Memory, Process, Threading, Time, Console, and Comm control(kernel32.dll) _hread_hwrite_lclose_lcr
    03-16
  • 一个基于API的VB.net串口通讯类 vbnet串口通信
    VB.net的串口通讯支持总是让人觉得有所不足,在使用VB6的MsComm32.ocx时,很多人都会在VB.net的开发中觉得很困扰。    这里讲述的VB.net串口通讯类使用native代码,并且它是通API调用实现的,你会发现VB.net的串口通讯就是这么简单。    在说明如何使
    02-12
  • [VB][ASP.NET]FileUpload控件「批次上传 / 多档
    FileUpload控件「批次上传 / 多档案同时上传」的范例 (VB语法) http://www.dotblogs.com.tw/mis2000lab/archive/2008/05/14/3986.aspx    FileUpload控件真的简单好用,不使用它来作批次上传,却要改用别的方法,实在不聪明。要用就一次用到底,公开File
    02-10
  • 第八章 VB中ActiveX控件的使用
    轉自:http://wwww.hyit.edu.cn/edu/vb/study/index.htm第八章          VB中ActiveX控件的使用8.1  概述     这里的ActiveX控件是指VB标准工具箱里没有的控件,用时需从“工程”菜单里选择“部件…”(或右键单击工具箱,从快捷菜单中选择“部
    02-10
  • 第二章 VB的界面设计
    轉自:http://wwww.hyit.edu.cn/edu/vb/study/index.htm第二章         VB的界面设计2.1  VB用户界面设计基础1. 概述   界面的设计有两步:先绘制控件,然后确定控件属性。   绘制控件:在工具箱里单击想画的控件,在窗体里按下鼠标并拖曳,然后
    02-10
  • C#/VB.NET 获取Excel中图片所在的行、列坐标位置
    C#/VB.NET 获取Excel中图片所在的行、列坐标位
    本文以C#和vb.net代码示例展示如何来获取Excel工作表中图片的坐标位置。这里的坐标位置是指图片左上角顶点所在的单元格行和列位置,横坐标即顶点所在的第几列、纵坐标即顶点所在的第几行。下面是获取图片位置的详细方法及步骤。【程序环境】按照如下方法来引
    02-09
  • VB操作XML
    VB操作XML
    XSL(可扩展样式表语言)是对CSS的一种扩展,功能比CSS强大得多。XML链接是在HTML链接的功能之上加以扩展,可以支持更为复杂的链接,通过XML链接,不仅可以在XML文件之间建立链接,还可以建立其他类型数据之间的链接,其规范分为三个部分:XLink语言,XPointe
    02-09
  • VB6多线程,关键段操作 vb6.0 多线程
    Option Explicit Declare Function GetLastError Lib "kernel32" () As Long 'Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long 'Declare Sub ExitThread Lib "kernel32" (Optional ByVal dwExitCode
    02-09
  • VB.NET调用IE,并且等待
                Dim p As New Process            '获得URL            aURL = GetURL()            '获得IE路径            p.StartInfo.FileName = System.Environment.GetFolderPath( _ 
    02-09
  • vb的VSFlexGrid控件 vb msflexgrid
    多行选中VSFlexGrid的SelectionMode = flexSelectionListBox,现在可以配合Ctrl进行多行选择循环取值用vsflexgrid.SelectedRows 可以得到你选择的行的总数量然后用循环可以得到具体的行中具体列的内容Dim Temp  As StringDim i As IntegerFor i =
    02-09
点击排行