0
Quelqu'un pourrait m'aider s'il vous plaît avec ce qui ne va pas ici? J'ai essayé d'ajouter un en-tête de sécurité, pour l'instant seulement contenant un nom d'utilisateur.Quicky: VB, XML et SOAP. Erreur mineure?
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
En outre, si quelqu'un pouvait me dire comment voir la chaîne xml serialise, ce serait fantastique. Merci –
Montrer du code et demander "qu'est-ce qui ne va pas ici" ne peut pas être considéré comme une vraie question. Vous devez nous dire ce que vous essayez d'accomplir, et ce qui se passe à la place. Par exemple, y a-t-il une exception avec un message? –
Si vous lisez l'introduction, il est assez évident que le problème est avec les lignes d'en-tête de sécurité. Mais c'est bien fait de traîner sur les forums en collant la même réponse partout où vous le pouvez, plutôt que d'admettre que vous ne savez pas, ou tout simplement rester silencieux comme vous le devriez quand vous ne savez pas. –