Appel WS en php - récupération des paramètres
Bonjour,
Je bloque depuis un moment sur la récupération dans le WS en Java des paramètres passés depuis une application PHP.
Le Web Services :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
@MTOM
@WebService(serviceName = "EditionServices")
public class EditionServices {
/**
* @param pEditionName
* @param pParams
* @param pFormat
* @return
* @throws EditionException
*/
@SuppressWarnings("deprecation")
@XmlMimeType("application/octet-stream")
@StreamingAttachment(parseEagerly = true, memoryThreshold = 16000L)
@WebMethod(action = "demandeEdition")
public DataHandler demandeEdition(
@WebParam(name = "name", targetNamespace = "http://services.editions.ws.lprg.xxxxxxxx.fr/") final String pEditionName,
@WebParam(name = "params", targetNamespace = "http://services.editions.ws.lprg.xxxxxxxx.fr/") Object[] pParams,
@WebParam(name = "format", targetNamespace = "http://services.editions.ws.lprg.xxxxxxxx.fr/") final String pFormat)
throws EditionException
(...)
} |
Après déploiement, le wsdl généré est :
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
|
<!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-752-.
-->
<!--
Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-752-.
-->
<definitions targetNamespace="http://services.editions.ws.lprg.xxxxxxxx.fr/" name="EditionServices">
<wsp:Policy wsu:Id="EditionServicesPortBinding_MTOM_Policy-EditionServicesPortBinding_MTOM_Policy">
<ns1:OptimizedMimeSerialization wsp:Optional="true"/>
</wsp:Policy>
<types>
<xsd:schema>
<xsd:import namespace="http://services.editions.ws.lprg.xxxxxxxx.fr/" schemaLocation="http://lswd1.cnasea.fr:9301/WSEditions/EditionServices?xsd=1"/>
</xsd:schema>
</types>
<message name="demandeEdition">
<part name="parameters" element="tns:demandeEdition"/>
</message>
<message name="demandeEditionResponse">
<part name="parameters" element="tns:demandeEditionResponse"/>
</message>
<message name="EditionException">
<part name="fault" element="tns:EditionException"/>
</message>
<portType name="EditionServices">
<operation name="demandeEdition">
<input wsam:Action="demandeEdition" message="tns:demandeEdition"/>
<output wsam:Action="http://services.editions.ws.lprg.xxxxxxxx.fr/EditionServices/demandeEditionResponse" message="tns:demandeEditionResponse"/>
<fault message="tns:EditionException" name="EditionException" wsam:Action="http://services.editions.ws.lprg.xxxxxxxx.fr/EditionServices/demandeEdition/Fault/EditionException"/>
</operation>
</portType>
<binding name="EditionServicesPortBinding" type="tns:EditionServices">
<wsp:PolicyReference URI="#EditionServicesPortBinding_MTOM_Policy-EditionServicesPortBinding_MTOM_Policy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="demandeEdition">
<soap:operation soapAction="demandeEdition"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="EditionException">
<soap:fault name="EditionException" use="literal"/>
</fault>
</operation>
</binding>
<service name="EditionServices">
<port name="EditionServicesPort" binding="tns:EditionServicesPortBinding">
<soap:address location="http://lswd1.cnasea.fr:9301/WSEditions/EditionServices"/>
</port>
</service>
</definitions> |
le xsd associé :
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
|
<!--
Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2-hudson-752-.
-->
<xs:schema version="1.0" targetNamespace="http://services.editions.ws.lprg.xxxxxxxx.fr/">
<xs:element name="EditionException" type="tns:EditionException"/>
<xs:element name="demandeEdition" type="tns:demandeEdition"/>
<xs:element name="demandeEditionResponse" type="tns:demandeEditionResponse"/>
<xs:complexType name="demandeEdition">
<xs:sequence>
<xs:element name="name" type="xs:string" form="qualified" minOccurs="0"/>
<xs:element name="params" type="xs:anyType" form="qualified" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="format" type="xs:string" form="qualified" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="demandeEditionResponse">
<xs:sequence>
<xs:element name="return" ns1:expectedContentTypes="application/octet-stream" type="xs:base64Binary" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="EditionException">
<xs:sequence>
<xs:element name="message" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema> |
Lorsque je demande une édition sans paramètres, cela fonctionne. Par contre lorsque j'appelle une édition en lui passant un tableau de paramètres, cela ne fonctionne pas. La trace de vidage des paramètres me donne :
Code:
1 2 3 4 5 6 7 8 9 10
|
|----------------------------------------|#]
|1|#]
|[Ljava.lang.Object;@57bc52|#]
|[ns1:params: null]|#]
|----------------------------------------|#] |
le code du client de test en PHP, basé sur les extensions SOAP de PHP (version 5) :
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
|
<?php
$wsdl = "http://lswd1.xxxxxxxx.fr:9301/WSEditions/EditionServices?wsdl" ;
$soapClient = new SoapClient($wsdl);
// Setup the RemoteFunction parameters
$ap_param = array(
'name' => 'testCUI'
,'params' => array (
'date_debut' => '01/07/2010'
,'date_fin' => '31/07/2010')
,'format' => 'PDF');
// Call RemoteFunction ()
$error = 0;
try {
$info = $soapClient->__call("demandeEdition", array($ap_param));
} catch (SoapFault $fault) {
$error = 1;
echo (" ERROR: ".$fault->faultcode."-".$fault->faultstring) ;
}
if ($error == 0) {
$output = $info->return ;
$newfile = "c:/temp/".$ap_param['name'].".".$ap_param['format'];
$file = fopen ($newfile, "w");
fwrite($file, $output);
fclose ($file);
// Kill the link to Soap
unset($soapClient);
}
?> |
Quelqu'un aurait-il déjà rencontré ce problème et trouvé la solution ?
Merci.