vb6.0 访问webservices

前端之家收集整理的这篇文章主要介绍了vb6.0 访问webservices前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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


猜你在找的VB相关文章