tags:

views:

36

answers:

1

Could someone please help me with what's wrong here? I have tried to add a security header, so far just containing a username.

Thanks

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
A: 

Sorted now and seems to be working. In true Stackoverflow spirit the answer will remain in my head, unpublished.