Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > Services Web
Services Web Forum d'entraide pour les services Web en PHP, qui permettent de créer et de consommer facilement des webservices (génération de WSDL etc.). Exemples : SOAP, NuSOAP, REST, SCA-SDO... Avant de poster -> Cours webservices
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 26/11/2007, 18h20   #1
Invité de passage
 
Inscription : avril 2005
Messages : 3
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 3
Points : 1
Points : 1
Envoyer un message via MSN à pudge
Par défaut [NuSOAP] Poblème d'envoi de paramètres "ComplexType" vers un WS

Bonjour,

Je rencontre un problème avec mon client NuSOAP (php 4.4) pour envoyer des paramètres "ComplexType" (tableaux associatifs) à mon Web Services sous Apache-Axis

Voici ma 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<definitions targetNamespace="http://mycompany.fr/mysystem/xmlio/">
	<!--
WSDL created by Apache Axis version: 1.3
Built on Oct 05, 2005 (05:23:37 EDT)
-->
	<wsdl:types>
	<schema elementFormDefault="qualified" targetNamespace="http://mycompany.fr/mysystem/xmlio/">
	<complexType name="XmlIoHeaderType">
	<sequence>
<element maxOccurs="1" minOccurs="0" name="SecurityId" nillable="true" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="SecurityToken" nillable="true" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="ProcessId" nillable="true" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="ParentId" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
	<complexType name="XmlIoRequest">
	<sequence>
<element name="XmlIoHeader" nillable="true" type="impl:XmlIoHeaderType"/>
<element name="ClassName" nillable="true" type="xsd:string"/>
<element name="OperationName" nillable="true" type="xsd:string"/>
<element name="XmlIoCurrentUrl" nillable="true" type="xsd:string"/>
<element name="XmlIoFinalUrl" nillable="true" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="XmlIn" nillable="true" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="XsdIn" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<element name="XmlIoRequest" type="impl:XmlIoRequest"/>
	<complexType name="XmlIoErrorType">
	<sequence>
<element name="ClassName" nillable="true" type="xsd:string"/>
<element name="Message" nillable="true" type="xsd:string"/>
<element maxOccurs="unbounded" minOccurs="0" name="StackElement" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
	<complexType name="XmlIoResponse">
	<sequence>
<element name="XmlIoHeader" nillable="true" type="impl:XmlIoHeaderType"/>
<element maxOccurs="1" minOccurs="0" name="XmlOut" nillable="true" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="XsdOut" nillable="true" type="xsd:string"/>
<element maxOccurs="1" minOccurs="0" name="XmlIoError" nillable="true" type="impl:XmlIoErrorType"/>
</sequence>
</complexType>
<element name="XmlIoResponse" type="impl:XmlIoResponse"/>
</schema>
</wsdl:types>
	<message name="xmlIoOperationRequest">
<part element="impl:XmlIoRequest" name="XmlIoRequest"/>
</message>
	<message name="xmlIoOperationResponse">
<part element="impl:XmlIoResponse" name="XmlIoResponse"/>
</message>
	<portType name="XmlIoPortType">
	<operation name="xmlIoOperation" parameterOrder="XmlIoRequest">
<input message="impl:xmlIoOperationRequest" name="xmlIoOperationRequest"/>
<output message="impl:xmlIoOperationResponse" name="xmlIoOperationResponse"/>
</operation>
</portType>
	<binding name="XmlIoPortTypeSoapBinding" type="impl:XmlIoPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
	<operation name="xmlIoOperation">
<wsdlsoap:operation soapAction=""/>
	<input name="xmlIoOperationRequest">
<wsdlsoap:body use="literal"/>
</input>
	<output name="xmlIoOperationResponse">
<wsdlsoap:body use="literal"/>
</output>
</operation>
</binding>
	<service name="XmlIoService">
	<port binding="impl:XmlIoPortTypeSoapBinding" name="XmlIoPortType">
<wsdlsoap:address location="http://myserver.mycompany.fr:7777/mysystemws/services/XmlIoPortType"/>
</port>
</service>
</definitions>
Voici mon client PHP NuSOAP correspondant :

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
		$proxyhost = '';
		$proxyport = '';
		$proxyusername = '';
		$proxypassword = '';
		$client = new soapclient('http://myserver.mycompany.fr:7777/mysystemws/services/XmlIoPortType', true,
								$proxyhost, $proxyport, $proxyusername, $proxypassword);
		$err = $client->getError();
		if ($err) {
			echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
		}
 
 
		$xmlioheader = array(	'SecurityId' => 'mylogin',
								'SecurityToken' => '00',
								'ProcessId' => '',
								'ParentId' => '');
 
		$param = array(	'XmlIoHeader' => $xmlioheader,
						'ClassName' => 'fr.mycompany.mysystem.outilsws.securite.SecWs',
						'OperationName' => 'allocateSgc',
						'XmlIoCurrentUrl' => '',
						'XmlIoFinalUrl' => '',
						'XmlIn' => '',
						'XsdIn' => ''
					  );
 
		//$namespace = 'XmlIoPortType';
 
		$result = $client->call('xmlIoOperation', $param);
 
 
		// Check for a fault
		if ($client->fault) {
			echo '<h2>Fault</h2><pre>';
			print_r($result);
			echo '</pre>';
		} else {
			// Check for errors
			$err = $client->getError();
			if ($err) {
				// Display the error
				echo '<h2>Error</h2><pre>' . $err . '</pre>';
			} else {
				// Display the result
				echo '<h2>Result</h2><pre>';
				print_r($result);
				echo '</pre>';
			}
		}
		echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
		echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
		echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

Et voici l'erreur que je récupère... :

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
Constructor error
 
wsdl error: XML error parsing WSDL from http://myserver.mycompany.fr:7777/mysystemws/services/XmlIoPortType on line 2: junk after document element
 
Fault
 
Array
(
    [faultcode] => soapenv:Server.userException
    [faultstring] => org.xml.sax.SAXException: Invalid element in fr.mycompany.mysystem.outilssvc.xmlio_soap.XmlIoRequest - XmlIoHeader
    [detail] => Array
        (
            [hostname] => myserver.mycompany.fr
        )
 
)
 
Request
 
POST /mysystemws/services/XmlIoPortType HTTP/1.0
Host: myserver.mycompany.fr:7777
User-Agent: NuSOAP/0.7.2 (1.94)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 1033
 
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns8471:xmlIoOperation xmlns:ns8471="http://tempuri.org"><XmlIoHeader><SecurityId xsi:type="xsd:string">mylogin</SecurityId><SecurityToken xsi:type="xsd:string">00</SecurityToken><ProcessId xsi:type="xsd:string"></ProcessId><ParentId xsi:type="xsd:string"></ParentId></XmlIoHeader><ClassName xsi:type="xsd:string">fr.mycompany.mysystem.outilsws.securite.SecWs</ClassName><OperationName xsi:type="xsd:string">allocateSgc</OperationName><XmlIoCurrentUrl xsi:type="xsd:string"></XmlIoCurrentUrl><XmlIoFinalUrl xsi:type="xsd:string"></XmlIoFinalUrl><XmlIn xsi:type="xsd:string"></XmlIn><XsdIn xsi:type="xsd:string"></XsdIn></ns8471:xmlIoOperation></SOAP-ENV:Body></SOAP-ENV:Envelope>
 
Response
 
HTTP/1.1 500 Internal Server Error
Date: Fri, 23 Nov 2007 18:24:33 GMT
Server: Oracle-Application-Server-10g/10.1.2.0.2 Oracle-HTTP-Server
Cache-Control: private
Connection: close
Content-Type: text/xml; charset=iso-8859-1
 
<?xml version="1.0" encoding="ISO-8859-1"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.userException</faultcode><faultstring>org.xml.sax.SAXException: Invalid element in fr.mycompany.mysystem.outilssvc.xmlio_soap.XmlIoRequest - XmlIoHeader</faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">myserver.mycompany.fr</ns1:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
Je ne sais pas trop d'où vient le problème de mon client, mais je suppose que l'erreur se produit car "XmlIoHeader" n'est pas typé dans la requête

Quelqu'un peut m'aider? Je débute avec les WS...
Merci d'avance!
pudge est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 26/11/2007, 18h27   #2
Invité de passage
 
Inscription : avril 2005
Messages : 3
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 3
Points : 1
Points : 1
Envoyer un message via MSN à pudge
Petite précision:

Au hasard de recherche d'exemples sur le net, j'ai tenté de typer chaque élément de mon tableau en utilisant "new soapval", mais je n'arrive pas à typer correctement "XmlIoHeader" qui est de type "impl:XmlIoHeaderType"

Comment puis-je définir son type? Ce n'est pourtant qu'un tableau associatif...

Voici mes modifs coté client :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
		$xmlioheader = array(	'SecurityId' => new soapval('SecurityId', 'string', 'login'),
								'SecurityToken' => new soapval('SecurityToken', 'string', '00'),
								'ProcessId' => new soapval('ProcessId', 'string', ''),
								'ParentId' => new soapval('ParentId', 'string', ''));
 
		$param = array(	'XmlIoHeader' => new soapval('XmlIoHeader', 'XmlIoHeaderType', $xmlioheader, false, 'impl'),
						'ClassName' => new soapval('ClassName', 'string', 'fr.mycompany.mysystem.outilsws.securite.SecWs'),
						'OperationName' => new soapval('OperationName', 'string', 'allocateSgc'),
						'XmlIoCurrentUrl' => new soapval('XmlIoCurrentUrl', 'string', ''),
						'XmlIoFinalUrl' => new soapval('XmlIoFinalUrl', 'string', ''),
						'XmlIn' => new soapval('XmlIn', 'string', ''),
						'XsdIn' => new soapval('XsdIn', 'string', '')
					  );
 
		$result = $client->call('xmlIoOperation', $param);
Une idée ?
pudge est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 28/11/2007, 16h54   #3
Invité de passage
 
Inscription : avril 2005
Messages : 3
Détails du profil
Informations forums :
Inscription : avril 2005
Messages : 3
Points : 1
Points : 1
Envoyer un message via MSN à pudge
J'ai trouvé !!

C'était un problème de namespace. J'ai du définir mon namespace pour chaque élément de mes paramètres avec "soapval" !
Ca me parait logique pour les "complexType" de ma WSDL, mais un peu étrange pour mes valeurs "string".
Peut-être un problème de définition des targetNamespace dans la WSDL...

Voici le code de mon client fonctionnel :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
		$client = new soapclient('http://myserver.mycompany.fr:7777/mysystemws/services/XmlIoPortType', false);
 
		$namespace = 'http://mycompany.fr/mysystem/xmlio/';
 
		$xmlioheader = array(	'SecurityId' => new soapval('SecurityId', 'string', 'login', $namespace),
								'SecurityToken' => new soapval('SecurityToken', 'string', '00', $namespace),
								'ProcessId' => new soapval('ProcessId', 'string', '', $namespace),
								'ParentId' => new soapval('ParentId', 'string', '', $namespace));
 
		$param = array(	'XmlIoHeader' => new soapval('XmlIoHeader', 'XmlIoHeaderType', $xmlioheader, $namespace),
						'ClassName' => new soapval('ClassName', 'string', 'fr.mycompany.mysystem.outilsws.securite.SecWs', $namespace),
						'OperationName' => new soapval('OperationName', 'string', 'allocateSgc', $namespace),
						'XmlIoCurrentUrl' => new soapval('XmlIoCurrentUrl', 'string', '', $namespace),
						'XmlIoFinalUrl' => new soapval('XmlIoFinalUrl', 'string', '', $namespace),
						'XmlIn' => new soapval('XmlIn', 'string', '', $namespace),
						'XsdIn' => new soapval('XsdIn', 'string', '', $namespace)
					  );
 
		$result = $client->call('xmlIoOperation', $param, $namespace);

J'espère que ça pourra aider quelqu'un !
pudge est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/03/2012, 10h11   #4
Candidat au titre de Membre du Club
 
Inscription : mars 2009
Messages : 84
Détails du profil
Informations forums :
Inscription : mars 2009
Messages : 84
Points : 11
Points : 11
Citation:
Envoyé par pudge Voir le message
J'ai trouvé !!

C'était un problème de namespace. J'ai du définir mon namespace pour chaque élément de mes paramètres avec "soapval" !
Ca me parait logique pour les "complexType" de ma WSDL, mais un peu étrange pour mes valeurs "string".
Peut-être un problème de définition des targetNamespace dans la WSDL...

Voici le code de mon client fonctionnel :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
		$client = new soapclient('http://myserver.mycompany.fr:7777/mysystemws/services/XmlIoPortType', false);
 
		$namespace = 'http://mycompany.fr/mysystem/xmlio/';
 
		$xmlioheader = array(	'SecurityId' => new soapval('SecurityId', 'string', 'login', $namespace),
								'SecurityToken' => new soapval('SecurityToken', 'string', '00', $namespace),
								'ProcessId' => new soapval('ProcessId', 'string', '', $namespace),
								'ParentId' => new soapval('ParentId', 'string', '', $namespace));
 
		$param = array(	'XmlIoHeader' => new soapval('XmlIoHeader', 'XmlIoHeaderType', $xmlioheader, $namespace),
						'ClassName' => new soapval('ClassName', 'string', 'fr.mycompany.mysystem.outilsws.securite.SecWs', $namespace),
						'OperationName' => new soapval('OperationName', 'string', 'allocateSgc', $namespace),
						'XmlIoCurrentUrl' => new soapval('XmlIoCurrentUrl', 'string', '', $namespace),
						'XmlIoFinalUrl' => new soapval('XmlIoFinalUrl', 'string', '', $namespace),
						'XmlIn' => new soapval('XmlIn', 'string', '', $namespace),
						'XsdIn' => new soapval('XsdIn', 'string', '', $namespace)
					  );
 
		$result = $client->call('xmlIoOperation', $param, $namespace);

J'espère que ça pourra aider quelqu'un !
Bonjour j'ai le même problème 5 ans après j'espère qu'il y aura quelqu'un pour m'aider.

Je n'arrive pas à transmettre des attributs de type complexe type.
Voici les attributs en question tels qu'ils sont définis dans la 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
<xs:complexType name="Request">
                <xs:attribute name="HubID" use="required">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">Value fixed by La Redoute</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:maxLength value="8"/>
                            <xs:minLength value="1"/>
                            <xs:pattern value="([0-9])+"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:attribute>
                <xs:attribute name="MessageDate" use="required" type="xs:dateTime">
                    <xs:annotation>
                        <xs:documentation xml:lang="en">Date and time of the message</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="MessageRelease" fixed="2.0" use="required" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Version number of the message</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
                <xs:attribute name="SellerID" use="required">
                    <xs:annotation>
                        <xs:documentation>Value fixed by La Redoute</xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="xs:string">
                            <xs:minLength value="1"/>
                            <xs:maxLength value="8"/>
                            <xs:pattern value="([0-9])+"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:attribute>
            </xs:complexType>
J'utilise Nusoap v 1.123 voici ce que je fais pour joindre mon webservice

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
$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';
$namespace = 'http://Redcats/Order/SellerOrder/2.0';
$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();
}
$params = array(
	'HubID' => '5',
	'SellerID' => $e_user_id,
	'MessageDate' => $now,
	'MessageRelease' => '2.0',
	'OrderID' => $orderId,
);
 
$result = $client->call('RetrieveSellerOrder_2.0Op', $params, $namespace);
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>';
 
}
Voici le message d'erreur que j'ai

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 "HubID" 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 "HubID" is required...
C'est le cas pour tous mes attributs.

Je suis complètement perdu.

Merci d'avance pour votre aide.

Cordialement
nkordiko est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 01h40.


 
 
 
 
Partenaires

Hébergement Web