Jump to content

Recommended Posts

Posted (edited)

Bonjour,

J'ai testé un serveur soap avec un client windows (SoapUI). Il me génère une trame un échange répondant ce que j'attends.

J'ai écrit un client SOAP en php pour faire la même chose mais qui lui ne fonctionne pas.

Entre les 2 tests, les entêtes sont identiques.

Voici la trame que je génère ; elle est refusée :

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlso.../soap/envelope/" xmlns:ns1="urn:productinfo">

<SOAP-ENV:Body>

<ns1:read>

<product>article</product>

<quantity>10</quantity>

</ns1:read>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>';

Voici la trame générée par soapUI. Elle est acceptée :

<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlso.../soap/envelope/" xmlns:urn="urn:productinfo">

<soapenv:Header/>

<soapenv:Body>

<urn:read>

<product>article1</product>

<quantity>1</quantity>

</urn:read>

</soapenv:Body>

</soapenv:Envelope>

Pour que ma trame soit acceptée, il suffit que je remplace "ns1" par "urn". Or je ne sait pas comment modifier ça en php.

Voici mon code


try {
$strheader =
"Content-Type: text/xml;charset=UTF-8\r\n" .
'SOAPAction: ""' . "\r\n" .
"Accept: text/plain\r\n" .
"Host: xxxxxxxxxx\r\n" .
"Connection: Keep-Alive\r\n" .
"User-Agent: Apache-HttpClient/4.1.1 (java 1.5)\r\n";
$context = stream_context_create( array("http"=>array( 'method' => 'POST', "header"=> $strheader), ) );
$options = array(
'login' => "xxxx",
'password' => 'xxx',
'location' => 'xxxxxxxxxxx/wssproductinfo.cgi',
"soap_version" => SOAP_1_1,
'trace' => 1,
'cache_wsdl' => 'WSDL_CACHE_NONE',
'stream_context' => $context
);
$client = new SoapClient( "http://www.xxxxxxx/productinfo.wsdl", $options );
echo '<pre>' . print_r( $client->read( array('product'=>"article",'quantity'=>'10') ),true );

} catch (Exception $e) {
echo "Trace= <pre>".print_r($e->getTrace(),true) . '<br>';
}

1/ Auriez vous une idée pour modifier mon "ns1" en "urn" ?

Merci de votre aide

Cordialement

Philippe

Edited by philippe69
  • 3 weeks later...
Posted

Hello,

Je pense que tu as la réponse dans une contribution de la doc :

http://www.php.net/m...quest.php#74123

Il te suffit donc d'étendre la classe Soapclient, et d'instancier cette classe étendue qui, à renfort de regex, redéfinit l'enveloppe soap.

Ton serveur est en asp.net ? (marrant, j'avais déjà fait sans souci, ou je me souviens plus)

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...