Bonjour,
J'essaye de connecter un site web à un web-service. Je développe donc un client soap.
Dans les spécs techniques du web-service, il est expliqué que l'authentification à ce web-service se fait dans les header des requetes Soap. On me donne un exemple de requete:
De mon coté, quand je construit ma requete Soap en mettant dans le header les informations nécessaire, ça me construit ça: (j'utilise la classe php http://php.net/manual/fr/class.soapclient.php )
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29POST /2011/01/01/ffip.asmx HTTP/1.1 Host: soap.ffip.fr Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "GetExport" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <AuthenticationInfo xmlns="http://soap.ffip.fr/2011/01/01/ffip.wsdl"> <softwareVersionKey xmlns="">string</softwareVersionKey> <softwarePassword xmlns="">string</softwarePassword> <realtorKey xmlns="">string</realtorKey> <userLogin xmlns="">string</userLogin> <userPassword xmlns="">string</userPassword> <cultureName xmlns="">string</cultureName> </AuthenticationInfo> </soap:Header> <soap:Body> <GetExport xmlns="http://soap.ffip.fr/2011/01/01/ffip.wsdl"> <idSoftware xmlns="">string</idSoftware> <AuthenticationInfo xmlns=""> <softwareVersionKey>string</softwareVersionKey> <softwarePassword>string</softwarePassword> </AuthenticationInfo> </GetExport> </soap:Body> </soap:Envelope>
Et quand j'envoi cette requete, je recupère une belle erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://soap.ffip.fr/2011/01/01/ffip.wsdl" xmlns:ns2="NAMESPACE"> <SOAP-ENV:Header> <ns2:AuthenticationInfo> <item> <key>SoftwareVersionKey</key> <value>truc</value> </item> <item> <key>SoftwarePassword</key> <value>machin</value> </item> </ns2:AuthenticationInfo> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns1:GetExport/> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Le code de mon client soap ("GetExport" est une des méthodes fournie par le web-service):
Code : Sélectionner tout - Visualiser dans une fenêtre à part soap:Client401 - SoftwareVersionKey is empty.
Ainsi voila ma question: la structure de ma requête n'étant pas exactement la même que la requête qui m'est donnée en exemple. Le problème vient-il de là, ou le serveur soap est-il censé savoir "tout lire"?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 $Wsdl = 'http://soap.ffip.fr/2011/01/01/ffip.asmx?WSDL'; $Auth = array( 'SoftwareVersionKey'=>$SoftwareVersionKey, 'SoftwarePassword'=>$SoftwarePassword, ); $Header = new SoapHeader($Wsdl,'AuthenticationInfo',$Auth,false); $Service = new SoapClient($Wsdl,array("trace" => 1)); $Service ->__setSoapHeaders($Header); try{ $Service ->GetExport(); } catch(SoapFault $Fault){ echo "SOAP Fault : ".$Fault; }
Et y'a-til d'autres classes php qui me permettraient de construire la requête comme sur l'exemple?
Merci d'avance
Partager