Se connecter au SOAP openESub depuis un programme VB6

De OpenESubWiki.

En premier lieu il vous faudra les bibliothéques 'Microsoft Soap type library' et 'Microsoft XML, v4.0'.


J'ai fait ici une méthode SOAP qui prevoit une commande et 4 arguments, s'il en faut moins il suffit de mettre une chaine vide.

 Private Const ENC = "http://schemas.xmlsoap.org/soap/encoding/"
 Private Const XSI = "http://www.w3.org/2001/XMLSchema-instance"
 Private Const XSD = "http://www.w3.org/2001/XMLSchema"
 Private URI As String
 Private Reponse_SOAP as String
 
   
 Private Sub Soap(methode, var1, var2, var3, var4)
   
   Dim Serializer As SoapSerializer
   Dim Reader As SoapReader
   Dim Connector As SoapConnector
   Set Connector = New HttpConnector
   Set Serializer = New SoapSerializer
   Set Reader = New SoapReader
   
   URI = "urn:" & "http://www.openesub.org"
   Connector.Property("EndPointURL") = "http://www.openesub.org/jeu/asynchrone/site/soap/soap.php"
   Call Connector.Connect
   Connector.Property("SoapAction") = URI & "#" & Method
   Call Connector.BeginMessage
   Serializer.Init Connector.InputStream
   Serializer.startEnvelope , ENC
   Serializer.SoapNamespace "xsi", XSI
   Serializer.SoapNamespace "SOAP-ENC", ENC
   Serializer.SoapNamespace "xsd", XSD
   Serializer.startBody
   
   Serializer.startElement methode, "http://www.openesub.org", , "ns1"
   Serializer.SoapAttribute "type", , "xsd:string", "xsi"
   If var1 <> "" Then
       Serializer.startElement "var1"
       Serializer.writeString var1
       Serializer.endElement
   End If
   If var2 <> "" Then
       Serializer.startElement "var2"
       Serializer.writeString var2
       Serializer.endElement
   End If
   If var3 <> "" Then
       Serializer.startElement "var3"
       Serializer.writeString var3
       Serializer.endElement
   End If
   If var4 <> "" Then
       Serializer.startElement "var4"
       Serializer.writeString var4
       Serializer.endElement
   End If
   
   Serializer.endElement
   Serializer.endBody
   Serializer.endEnvelope
   Connector.EndMessage
   
   Reader.Load Connector.OutputStream
   
   If Not Reader.Fault Is Nothing Then
       MsgBox Reader.faultstring.Text, vbExclamation
   Else
       GetTagValueArray Reader.DOM, methode & "Response", Reponse_SOAP
   End If
   
 End Sub


On appelle la fonction SOAP en envoyant la commande et les paramètres

Ping()

 call Soap ("ping","","","","")

getZdop (nmr zdop)

 call Soap ("getZdop","78","","","")

etc...

La chaine de réponse se retrouve dans la variable Reponse_SOAP les différentes valeurs sont séparées par un chr(10).

Outils personnels