[SOAP] soapClient : requete complexe
J'ai un problème pour les requêtes complexes SOAP avec l'objet soapClient de php5
PHP Version 5.3.3-1 sous ubuntu9.10
Voici la requête SOAP que je voudrais envoyé (ici le code est en xml pour mieux le visualiser)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:epcglobal:epcis-query:xsd:1">
<soapenv:Header/>
<soapenv:Body>
<urn:Poll>
<queryName>SimpleEventQuery</queryName>
<params>
<param>
<name>EQ_action</name>
<value>
<string>ADD</string>
<string>OBSERVE</string>
<string>DELETE</string>
</value>
</param>
</params>
</urn:Poll>
</soapenv:Body>
</soapenv:Envelope> |
Et voici le code PHP que j'utilise pour effectuer l'appel SOAP (donc l utilisation de SoapClient pour consumer un webservice distant via un WSDL)
Code:
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 54 55
|
<?php
/**
* Cree un client soap pour consommer un webService
* On utilise l objet SoapClient de PHP http://www.php.net/manual/fr/soapclient.soapclient.php
* RMQ : la config du proxy est dans le fichier de configuration "conf/conf/network.cfg.php"
*
* @param boolean $proxy
* @return \SoapClient
*/
private function getSoapclient($proxy = false)
{
$options = array("soap_version" => SOAP_1_1,
"encoding" => "UTF-8",
"trace" => true,
"exceptions" => true);
//creation d'un objet soapClient par connexion proxy
$soapClient = new SoapClient($this->urlWSDL, $options);
return $soapClient;
}
public function testSoap()
{
$soapClient = $this->getSoapclient();
$functionArguments = new stdClass();
$functionArguments->queryName = "SimpleEventQuery";
$paramMatchEpc = new stdClass();
$paramMatchEpc->name = "EQ_action";
$paramMatchEpc->value = new stdClass();
$paramMatchEpc->value->string = array("ADD", "OBSERVE", "DELETE");
$arrayArguments = array($paramMatchEpc);
$functionArguments->params = new stdClass();
$functionArguments->params->param = $arrayArguments;
try
{
$results = $soapClient->poll($functionArguments);
/**/error_log(print_r($results, true));
}
catch (Exception $exc)
{
/**/error_log("ERREUR !");
/**/error_log(print_r($exc, true));
$results = null;
}
return $results;
}
?> |
Le code produit pour l'appel Soap n'est pas correct et provoque une horreur une erreur :p
(le code devrait être identique à la première section de code que j'ai posté plus haut)
Voici le code que j'obtiens (code qui n'est pas correct)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="urn:epcglobal:epcis-query:xsd:1">
<SOAP-ENV:Body>
<ns1:Poll>
<queryName>SimpleEventQuery</queryName>
<params>
<param>
<name>EQ_action</name>
<value>
<string>
<xsd:string>ADD</xsd:string>
<xsd:string>OBSERVE</xsd:string>
<xsd:string>DELETE</xsd:string>
</string>
</value>
</param>
</params>
</ns1:Poll>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
Le problème provient du array de value dans le passage de paramètres car le serveurSoap ou php convertit implicitement mes strings comme des noeuds <xsd:string>MonString</xsd:string>
Cela fait plusieurs jours que je suis dessus et je ne trouve pas de solution...
Si une personne à une idée je suis preneur ^^
voici le WSDL à disposition (c'est un WSDL faisait partie d un projet open source nommé fosstrak)
Code:
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
| <?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="QueryOperationsWebServiceService" targetNamespace="http://query.repository.epcis.fosstrak.org/" xmlns:ns1="urn:epcglobal:epcis:wsdl:1" xmlns:ns3="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://query.repository.epcis.fosstrak.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:import location="http://localhost:8080/epcis-repository-0.5.0/query/?wsdl=EPCISServicePortType.wsdl" namespace="urn:epcglobal:epcis:wsdl:1">
</wsdl:import>
<wsdl:binding name="QueryOperationsWebServiceServiceSoapBinding" type="ns1:EPCISServicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getQueryNames">
<soap:operation soapAction="" style="document" />
<wsdl:input name="getQueryNames">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getQueryNamesResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ImplementationExceptionResponse">
<soap:fault name="ImplementationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ValidationExceptionResponse">
<soap:fault name="ValidationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SecurityExceptionResponse">
<soap:fault name="SecurityExceptionResponse" use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="unsubscribe">
<soap:operation soapAction="" style="document" />
<wsdl:input name="unsubscribe">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="unsubscribeResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ImplementationExceptionResponse">
<soap:fault name="ImplementationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ValidationExceptionResponse">
<soap:fault name="ValidationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="NoSuchSubscriptionExceptionResponse">
<soap:fault name="NoSuchSubscriptionExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SecurityExceptionResponse">
<soap:fault name="SecurityExceptionResponse" use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="poll">
<soap:operation soapAction="" style="document" />
<wsdl:input name="poll">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="pollResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="QueryTooComplexExceptionResponse">
<soap:fault name="QueryTooComplexExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ImplementationExceptionResponse">
<soap:fault name="ImplementationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="QueryParameterExceptionResponse">
<soap:fault name="QueryParameterExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ValidationExceptionResponse">
<soap:fault name="ValidationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="QueryTooLargeExceptionResponse">
<soap:fault name="QueryTooLargeExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SecurityExceptionResponse">
<soap:fault name="SecurityExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="NoSuchNameExceptionResponse">
<soap:fault name="NoSuchNameExceptionResponse" use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="subscribe">
<soap:operation soapAction="" style="document" />
<wsdl:input name="subscribe">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="subscribeResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="QueryTooComplexExceptionResponse">
<soap:fault name="QueryTooComplexExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ImplementationExceptionResponse">
<soap:fault name="ImplementationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SubscriptionControlsExceptionResponse">
<soap:fault name="SubscriptionControlsExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="QueryParameterExceptionResponse">
<soap:fault name="QueryParameterExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ValidationExceptionResponse">
<soap:fault name="ValidationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="DuplicateSubscriptionExceptionResponse">
<soap:fault name="DuplicateSubscriptionExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SecurityExceptionResponse">
<soap:fault name="SecurityExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="NoSuchNameExceptionResponse">
<soap:fault name="NoSuchNameExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SubscribeNotPermittedExceptionResponse">
<soap:fault name="SubscribeNotPermittedExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="InvalidURIExceptionResponse">
<soap:fault name="InvalidURIExceptionResponse" use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getVendorVersion">
<soap:operation soapAction="" style="document" />
<wsdl:input name="getVendorVersion">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getVendorVersionResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ImplementationExceptionResponse">
<soap:fault name="ImplementationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ValidationExceptionResponse">
<soap:fault name="ValidationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SecurityExceptionResponse">
<soap:fault name="SecurityExceptionResponse" use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getStandardVersion">
<soap:operation soapAction="" style="document" />
<wsdl:input name="getStandardVersion">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getStandardVersionResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ImplementationExceptionResponse">
<soap:fault name="ImplementationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ValidationExceptionResponse">
<soap:fault name="ValidationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SecurityExceptionResponse">
<soap:fault name="SecurityExceptionResponse" use="literal" />
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="getSubscriptionIDs">
<soap:operation soapAction="" style="document" />
<wsdl:input name="getSubscriptionIDs">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getSubscriptionIDsResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="ImplementationExceptionResponse">
<soap:fault name="ImplementationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="ValidationExceptionResponse">
<soap:fault name="ValidationExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="SecurityExceptionResponse">
<soap:fault name="SecurityExceptionResponse" use="literal" />
</wsdl:fault>
<wsdl:fault name="NoSuchNameExceptionResponse">
<soap:fault name="NoSuchNameExceptionResponse" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="QueryOperationsWebServiceService">
<wsdl:port binding="tns:QueryOperationsWebServiceServiceSoapBinding" name="QueryOperationsWebServicePort">
<soap:address location="http://localhost:8080/epcis-repository-0.5.0/query/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |