Bonjour,

Dans une requête SOAP, je cherche comment envoyer un type complexe en paramètre.

Voici mon fichier WSDL avec mon type complexe "information".
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="test" targetNamespace="urn:WS/wsdl"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:WS/wsdl" xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
    <types>
        <xsd:schema targetNamespace="urn:WS/wsdl" xmlns:tns="urn:WS/wsdl">
            <xsd:complexType name="information">
                <xsd:sequence>
                    <xsd:element name="version" type="xsd:string"></xsd:element>
                    <xsd:element name="id" type="xsd:int"></xsd:element>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </types>
    <message name="getDateRequest"/>
    <message name="getDateResponse">
        <part name="date" type="xsd:date"/>
    </message>
    <message name="getXmlRequest">
        <part name="information" type="tns:information"/>
    </message>
    <message name="getXmlResponse">
        <part name="version" type="xsd:string"/>
    </message>
    <portType name="Date">
        <operation name="getDate">
            <input name="input1" message="tns:getDateRequest"/>
            <output name="output1" message="tns:getDateResponse"/>
        </operation>
        <operation name="getXml">
            <input name="input2" message="tns:getXmlRequest"/>
            <output name="output2" message="tns:getXmlResponse"/>
        </operation>
    </portType>
    <binding name="testBinding" type="tns:Date">
        <soap12:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="getDate">
            <soap12:operation/>
            <input name="input1">
                <soap12:body use="literal" namespace="urn:WS/wsdl"/>
            </input>
            <output name="output1">
                <soap12:body use="literal" namespace="urn:WS/wsdl"/>
            </output>
        </operation>
        <operation name="getXml">
            <input name="input2"/>
            <output name="output2"/>
        </operation>
    </binding>
    <service name="testService">
        <port name="testPort" binding="tns:testBinding">
            <soap12:address location="http://127.0.0.1:1004/webservice/server.php"/>
        </port>
    </service>
    <plnk:partnerLinkType name="test">
        <!-- A partner link type is automatically generated when a new port type is added. Partner link types are used by BPEL processes.
In a BPEL process, a partner link represents the interaction between the BPEL process and a partner service. Each partner link is associated with a partner link type.
A partner link type characterizes the conversational relationship between two services. The partner link type can have one or two roles.-->
        <plnk:role name="DateRole" portType="tns:Date"/>
    </plnk:partnerLinkType>
</definitions>
Mon type complexe "information " est constitué d'un élément "version" et "id".

Après quelques essaies, je ne parviens pas du côté client à envoyer ces paramètres dans un appel de méthode "getXml".
Voici ce que j'ai essayé de faire.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
$client = new SoapClient('http://127.0.0.1:1004/webservice/test.wsdl', array('trace' => 1, 'soap_version'  => SOAP_1_2));
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
    $xml .= '<SOAP-ENV:Envelope 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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">';
    $xml .= '<SOAP-ENV:Body>';
    $xml .= '<SOAP-ENV:getXml>';
        $xml .= '<information>';
            $xml .= '<version>test version</version>';
            $xml .= '<id>55555</id>';
        $xml .= '</information>';
    $xml .= '</SOAP-ENV:getXml>';
    $xml .= '</SOAP-ENV:Body>';
    $xml .= '</SOAP-ENV:Envelope>';
echo $client->getXml($xml);
Comment travailler avec un type complexe ?
Comment le fournir en paramètre côté client et comment le récupérer côté serveur ?

Je suis preneur de tous conseils.

Merci.