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

vb6.0 访问webservices

发布时间:2020-12-17 07:37:41 所属栏目:百科 来源:网络整理
导读:Option ExplicitPrivate Const Method = "helloworld"Private Const SoapAction = _"http://127.0.0.1/helloworld/HelloWorld"Private Const END_POINT_URL = _"http://127.0.0.1/helloworld/Service.asmx?WSDL"Private Const CALC_NS = "http://127.0.0.1/h
Option Explicit
Private Const Method = "helloworld"
Private Const SoapAction = _
"http://127.0.0.1/helloworld/HelloWorld"
Private Const END_POINT_URL = _
"http://127.0.0.1/helloworld/Service.asmx?WSDL"
Private Const CALC_NS = "http://127.0.0.1/helloworld/"
Private Function Execute() As String
    
    Dim Serializer As SoapSerializer30
    Dim Reader As SoapReader30
    Dim ResultElm As IXMLDOMElement
    Dim FaultElm As IXMLDOMElement
    Dim Connector As SoapConnector30
    
    Set Connector = New HttpConnector30
    On Error GoTo ErrHandle
    Connector.Property("EndPointURL") = END_POINT_URL
    Connector.Connect
    
    ' binding/operation/soapoperation
    Connector.Property("SoapAction") = SoapAction
    Connector.BeginMessage
    
    Set Serializer = New SoapSerializer30
    Serializer.Init Connector.InputStream
    
    'Serializer.StartEnvelope "SOAP","http://schemas.xmlsoap.org/soap/envelope/",""
    'Serializer.SoapAttribute "xsi","","http://www.w3.org/2001/XMLSchema-instance","xmlns"
    'Serializer.SoapAttribute "xsd","http://www.w3.org/2001/XMLSchema","xmlns"
    
    Serializer.StartEnvelope
    Serializer.StartBody
    Serializer.StartElement Method,CALC_NS
    Serializer.EndElement
    Serializer.EndBody
    Serializer.EndEnvelope
    
    Connector.EndMessage
        
    Set Reader = New SoapReader30
    Reader.Load Connector.OutputStream
    
    If Not Reader.Fault Is Nothing Then
        MsgBox Reader.FaultString.Text,vbExclamation
    Else
        Execute = Reader.RpcResult.xml
    End If
    Exit Function
ErrHandle:
    MsgBox Err.Description,vbExclamation,"错误"

End Function

Private Sub Command1_Click()
MsgBox Execute()
End Sub


(编辑:李大同)

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

    推荐文章
      热点阅读