有人可以帮我解决这里的错误吗?我试图添加一个安全标头,到目前为止只包含一个用户名。
Dim ENC As String
Dim XSI As String
Dim XSD As String
Sub SOAPsuds()
'Define Envelope Constants
ENC = "http://schemas.xmlsoap.org/soap/encoding/" 'Encoding
XSI = "http://www.w3.org/1999/XMLSchema-instance" 'Schema Instance
XSD = "http://www.w3.org/1999/XMLSchema" 'Schema
WSSE = "http://schemas.xmlsoap.org/ws/2002/12/secext"
'Define Envelope Variables
URL = "http://62.32.110.194/PartService.asmx?wsdl" 'Web Service
Uri = "msg:dtl" 'Hmm...?
Method = "GetList" 'Web Method
'Instantiate things
Dim Connector As SoapConnector30
Dim Serializer As SoapSerializer30
Dim Reader As SoapReader30
Set Connector = New HttpConnector30
Set Serializer = New SoapSerializer30
Set Reader = New SoapReader30
'Prepare the Connector to talk to the SOAP Server
Connector.Property("EndPointURL") = URL
Call Connector.Connect
Connector.Property("SoapAction") = Uri & "#" & Method
Call Connector.BeginMessage
'Associate Serializer with Connector
Serializer.Init Connector.InputStream
'Start the SOAP Envelope and specify the Encoding and XML-Schema
Serializer.StartEnvelope , ENC
Serializer.SoapNamespace "xsi", XSI
Serializer.SoapNamespace "SOAP-ENC", ENC
Serializer.SoapNamespace "xsd", XSD
Serializer.SoapNamespace "wsse", WSSE
'Start the header of the message 'New header
Serializer.StartHeader
Serializer.Element "Security", "wsse"
Serializer.Element "UsernameToken", "wsse"
Serializer.Element "Username", "wsse"
Serializer.SoapAttribute "type", , "xsd:string", "xsi"
Serializer.WriteString "the_username"
Serializer.EndElement
Serializer.EndElement
Serializer.EndElement
Serializer.EndHeader
'Start the body of the message
Serializer.StartBody
Serializer.StartElement Method, Uri, , "method"
'Write each method parameter out as a child to the root element
Serializer.StartElement "Author"
Serializer.SoapAttribute "type", , "xsd:string", "xsi"
Serializer.WriteString "Wilde, Oscar"
Serializer.EndElement
'End the root element, the body and the envelope
Serializer.EndElement
Serializer.EndBody
Serializer.EndEnvelope
'Ending the message causes it to be sent
Connector.EndMessage
'Load the result into the Reader
Reader.Load Connector.OutputStream
'If ok then pull result out of DOM
If Not Reader.Fault Is Nothing Then
MsgBox Reader.FaultString.text, vbExclamation
Else
Set Result = Reader.Dom
'//parse the DOM to extract the result set
End If
End Sub
答案 0 :(得分:0)
现在排序,似乎正在运作。在真正的Stackoverflow精神中,答案将保留在我的脑海中,未发表。