[Webservice][SOAP] Output Data Invalid

Eléphanteau du PHP | 38 Messages

21 mars 2012, 12:03

Bonjour , je suis débutant en Soap.
je souhaite mettre en place un webservice me permettant de mettre à jour mon flux catalogue et récupérer mes commandes sur un site distant.

Le problème se pose pour la récupération des commandes.

J'utilise la librairie Nusoap avec la wsdl qui m'a été fourni(cf pièce jointe). Les attributs demandés ne sont pas identifiés alors qu'ils sont bien dans le array envoyé.

Mon code
<?php

require_once('lib/nusoap.php');
require_once('lib/nusoapmime.php');
$e_user_id = "2229";
$orderId = "20120660222901";
$now = date('Y-m-d\TH:i:s');
$client = new nusoap_client_mime('laredoute-order.wsdl', true);
$client->soap_defencoding = 'utf-8';
$err = $client->getError();
if ($err) {
	echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
	echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
	exit();
}
[color=#FF0000]$params = array(
	'HubID' => '5',
	'SellerID' => $e_user_id,
	'MessageDate' => $now,
	'MessageRelease' => '2.0',
	'OrderID' => $orderId,
);
$result = $client->call('RetrieveSellerOrder_2.0Op', $params);[/color]
if ($client->fault) {
	echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>'; print_r($result); echo '</pre>';
} else {
	
	$err = $client->getError();
	if ($err) {
		echo '<h2>Error</h2><pre>' . $err . '</pre>';
	}
	echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
	
}

?>
Maintenant mon message d'erreur

Code : Tout sélectionner

Array ( [faultcode] => SOAP-ENV:Server [faultstring] => This is an operation implementation generated fault [faultactor] => [detail] => Array ( [Fault_1.0] => Array ( [FaultId] => VALI_010 [FaultMessage] => Input data invalid [FaultTrace] => [BusinessServices/RCA_Order_2.0/Interface/RetrieveSellerOrder_2.0.process/Start] Output data invalid at com.tibco.pe.core.ProcessGroup.a(Unknown Source) at com.tibco.pe.core.ProcessGroup.eval(Unknown Source) at com.tibco.pe.plugin.Activity.eval(Unknown Source) at com.tibco.pe.core.TaskImpl.eval(Unknown Source) at com.tibco.pe.core.Job.a(Unknown Source) at com.tibco.pe.core.Job.k(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source) caused by: org.xml.sax.SAXException: validation error: attribute [color=#FF0000]"HubID"[/color] is required ({com.tibco.xml.validation}COMPLEX_E_MISSING_ATTRIBUTE) at /{http://Redcats/Order/SellerOrder/2.0}RetrieveSellerOrderRequest_2.0[1]/parameters[1]/RetrieveSellerOrderRequest_2.0[1] com.tibco.xml.validation.exception.MissingAttributesException: attribute [color=#FF0000]"HubID"[/color] is required at com.tibco.xml.validation.state.driver.ValidationJazz.a(ValidationJazz.java:821) at com.tibco.xml.validation.state.driver.ValidationJazz.endAttributes(ValidationJazz.java:790) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:87) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:92) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:92) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:129) at com.tibco.xml.xdata.bind.BindingRunner.validate(Unknown Source) at com.tibco.pe.core.ProcessGroup.a(Unknown Source) at com.tibco.pe.core.ProcessGroup.eval(Unknown Source) at com.tibco.pe.plugin.Activity.eval(Unknown Source) at com.tibco.pe.core.TaskImpl.eval(Unknown Source) at com.tibco.pe.core.Job.a(Unknown Source) at com.tibco.pe.core.Job.k(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source) validation error: attribute [color=#FF0000]"SellerID"[/color] is required ({com.tibco.xml.validation}COMPLEX_E_MISSING_ATTRIBUTE) at /{http://Redcats/Order/SellerOrder/2.0}RetrieveSellerOrderRequest_2.0[1]/parameters[1]/RetrieveSellerOrderRequest_2.0[1] com.tibco.xml.validation.exception.MissingAttributesException: attribute [color=#FF0000]"SellerID"[/color] is required at com.tibco.xml.validation.state.driver.ValidationJazz.a(ValidationJazz.java:821) at com.tibco.xml.validation.state.driver.ValidationJazz.endAttributes(ValidationJazz.java:790) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:87) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:92) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:92) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:129) at com.tibco.xml.xdata.bind.BindingRunner.validate(Unknown Source) at com.tibco.pe.core.ProcessGroup.a(Unknown Source) at com.tibco.pe.core.ProcessGroup.eval(Unknown Source) at com.tibco.pe.plugin.Activity.eval(Unknown Source) at com.tibco.pe.core.TaskImpl.eval(Unknown Source) at com.tibco.pe.core.Job.a(Unknown Source) at com.tibco.pe.core.Job.k(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source) validation error: attribute [color=#FF0000]"MessageDate"[/color] is required ({com.tibco.xml.validation}COMPLEX_E_MISSING_ATTRIBUTE) at /{http://Redcats/Order/SellerOrder/2.0}RetrieveSellerOrderRequest_2.0[1]/parameters[1]/RetrieveSellerOrderRequest_2.0[1] com.tibco.xml.validation.exception.MissingAttributesException: attribute [color=#FF0000]"MessageDate"[/color] is required at com.tibco.xml.validation.state.driver.ValidationJazz.a(ValidationJazz.java:821) at com.tibco.xml.validation.state.driver.ValidationJazz.endAttributes(ValidationJazz.java:790) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:87) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:92) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:92) at com.tibco.xml.validation.state.glue.XmlTreeNodeValidationDriver.xmlTreeNode(XmlTreeNodeValidationDriver.java:129) at com.tibco.xml.xdata.bind.BindingRunner.validate(Unknown Source) at com.tibco.pe.core.ProcessGroup.a(Unknown Source) at com.tibco.pe.core.ProcessGroup.eval(Unknown Source) at com.tibco.pe.plugin.Activity.eval(Unknown Source) at com.tibco.pe.core.TaskImpl.eval(Unknown Source) at com.tibco.pe.core.Job.a(Unknown Source) at com.tibco.pe.core.Job.k(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source) at com.tibco.xml.xdata.bind.BindingRemarkHandler.assertNoErrors(Unknown Source) at com.tibco.xml.xdata.bind.BindingRunner.validate(Unknown Source) at com.tibco.pe.core.ProcessGroup.a(Unknown Source) at com.tibco.pe.core.ProcessGroup.eval(Unknown Source) at com.tibco.pe.plugin.Activity.eval(Unknown Source) at com.tibco.pe.core.TaskImpl.eval(Unknown Source) at com.tibco.pe.core.Job.a(Unknown Source) at com.tibco.pe.core.Job.k(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.a(Unknown Source) at com.tibco.pe.core.JobDispatcher$JobCourier.run(Unknown Source) [TrcTs] => 2012-03-21T09:35:44.51+01:00 [msgID] => 3a14X5O1n1kDQpZwxhxZLe6HduM= ) ) )
Il faut savoir que je ne suis pas encore en prod mais en recette et je fais mes tests avec easyPhp

Dans le message d'erreur en rouge vous verrez les attributs manquants mais qui sont bien transmis en rouge dans mon code.

Merci d'avance pour votre compréhension.

Cordialement
Vous n’avez pas les permissions nécessaires pour voir les fichiers joints à ce message.
Nats

ViPHP
ViPHP | 2577 Messages

21 mars 2012, 12:28

Dans ton fichier, il y a : <xs:attribute name="HubID" use="required">
et dans le message, il y a : caused by: org.xml.sax.SAXException: validation error: attribute "HubID" is required

Soit tu ajoutes cet attribut HubID, soit tu le rends non obligatoire.

(je ne suis pas un pro de soap)

Edit : il n'y a pas une confusion entre attribut et parametre ?

Eléphanteau du PHP | 38 Messages

21 mars 2012, 12:49

Salut Mazarini,

D'après ce que tu dis je transmettrais des paramètres et non des attributs.

Dans mon cas, comment est ce que je pourrais transmettre des attributs et non des paramètres comme je semble le faire?
Nats

ViPHP
ViPHP | 2577 Messages

21 mars 2012, 14:39

Je ne connais pas assez soap.

Tu peux regarder http://www.scottnichol.com/nusoapprogwsdl.htm et t'inspirer de l'exemple. Leur wsdl ne semble pas correspondre au tien.

Eléphanteau du PHP | 38 Messages

21 mars 2012, 15:30

Mazarini je ne vois pas de différence avec ce que je fais.

Dans l'exemple:
$result = $client->call('hello', array('name' => 'Scott'));

Moi j'ai
$params = array(
'HubID' => '5',
'SellerID' => $e_user_id,
'MessageDate' => $now,
'MessageRelease' => '2.0',
'OrderID' => $orderId,
);

$result = $client->call('RetrieveSellerOrder_2.0Op', $params);

par contre dans la wsdl de l'exemple nul part il n'est mentionné de name est un attribut alors que dans wsdl pour HubID par exemple j'ai bien
<xs:attribute name="HubID" use="required">

Dans tous les cas merci pour ton aide tu m'as mis sur une piste
Nats