Bonjour à tous,
J'ai un (gros) problème lors de l'utilisation de SOAP. En fait, les arguments ne passent pas lorsque j'appelle une fonction !
Fichier wsdl
Code XML : 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 <?xml version="1.0" encoding="UTF-8" standalone="no"?> <wsdl:definitions xmlns:psx="http://print-site.d-sites.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="print-site4" targetNamespace="http://print-site.d-sites.com"> <wsdl:types> <xsd:schema targetNamespace="http://print-site.d-sites.com"> <xsd:element name="getImageUrl"> <xsd:complexType> <xsd:sequence> <xsd:element name="url" type="xsd:string" /> <xsd:element name="size" type="xsd:string"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="getImageUrlResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="out" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types> <wsdl:message name="getImageUrlRequest"> <wsdl:part element="psx:getImageUrl" name="parameters"/> </wsdl:message> <wsdl:message name="getImageUrlResponse"> <wsdl:part element="psx:getImageUrlResponse" name="parameters"/> </wsdl:message> <wsdl:portType name="print-site4"> <wsdl:operation name="getImageUrl"> <wsdl:input message="psx:getImageUrlRequest"/> <wsdl:output message="psx:getImageUrlResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="print-site4SOAP" type="psx:print-site4"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="getImageUrl"> <soap:operation soapAction="http://print-site.d-sites.com/getImageUrl" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="print-site4"> <wsdl:port binding="psx:print-site4SOAP" name="print-site4SOAP"> <soap:address location="http://print-site.d-sites.com/soap"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Server
Le client:
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 <?php function getImageUrl ($url, $size = 'real') { if (!Check::url($url)) { throw new SoapFault('error', 'L\'adresse URL est invalide'); } return 'Image of '.$url; } $server = new SoapServer('fichier.wsdl', array( 'encoding' => 'utf-8', 'cache_wsdl' => WSDL_CACHE_NONE ) ); $server->addFunction('getImageUrl'); $server->handle(); ?>
En voici le retour de __getLastRequest :
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 <?php try { $client = new SoapClient('http://url/fichier.wsdl', array('wsdl_cache', WSDL_CACHE_NONE, "trace" => 1)); echo 'Soap Client created'; $url = $client->getImageUrl('http://www.google.com'); var_dump($url); echo $client->__getLastRequest(); echo $client->__getLastResponse(); } catch (SoapFault $exception) { echo $client->__getLastRequest(); echo $client->__getLastResponse(); trigger_error('SOAP Exception: '.$exception, E_USER_ERROR); } ?>
Et de __getLastResponse
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://print-site.d-sites.com"><SOAP-ENV:Body><ns1:getImageUrl/></SOAP-ENV:Body></SOAP-ENV:Envelope>
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>error</faultcode><faultstring>L'adresse URL est invalide</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Aux vues de la requête envoyée, j'en conclu que l'argument n'est pas envoyé...
Avez-vous une piste ?
Merci !
Partager