Bonjour,
Je débute avec SoapServer et j'ai des petits problèmes.
Lorsque j'utilise des types simples comme int ou string je n'ai pas de problème lors des requêtes que j'effectue dans un logiciel que je programme en c# mais lorsque j'utilise des complexType je récupére à tous les coups un résultat null.
la partie de mon WSDL concerné :
Code xml : 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
64
65
66
67
68
69
70 <?xml version="1.0" encoding="UTF-8" ?> <definitions name="AmeliusWS" targetNamespace="http://xxxx" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xxxx" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <types> <xsd:schema targetNamespace="http://xxx"> [...] <xsd:complexType name="keyword"> <xsd:sequence> <xsd:element name="id_kw" type="xs:int" minOccurs="1" maxOccurs="1"/> <xsd:element name="nom" type="xs:string" minOccurs="1" maxOccurs="1"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="keywordsList" final="#all"> <xsd:sequence> <xsd:element name="item" type="tns:keyword" minOccurs="0" maxOccurs="unbounded" nillable="true"/> </xsd:sequence> </xsd:complexType> [...] </xsd:schema> </types> <message name="getKeywords"> <part name="ts" type="xsd:int" /> <part name="sign" type="xsd:string" /> </message> <message name="getKeywordsResponse"> <part name="ts" type="xsd:int" /> <part name="keywordsList" type="tns:keywordList" /> <part name="sign" type="xsd:string" /> </message> [...] <portType name="AmeliusWS"> <operation name="getKeywords"> <input message="tns:getKeywords"/> <output message="tns:getKeywordsResponse"/> </operation> [...] </portType> <binding name="AmeliusWSPortBinding" type="tns:AmeliusWS"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> <operation name="getKeywords"> <soap:operation soapAction=""/> <input> <soap:body use="literal" namespace="http://xxx"/> </input> <output> <soap:body use="literal" namespace="http://xxx"/> </output> </operation> [...] </binding> <service name="AmeliusWS"> <port name="AmeliusWSPort" binding="tns:AmeliusWSPortBinding"> <soap:address location="http://xxx"/> </port> </service> </definitions>
Je précise que ce wsdl fonctionne parfaitement dés lors que je n'utilise pas les complexType
mon code php gérant ce service :
Code php : 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 <?php namespace Adp\AmeliusBundle\Services; use Doctrine\Bundle\DoctrineBundle\Registry; use Adp\PageBundle\Entity\Keyword; class CT_KeywordsList { var $item; public function addItem($item) { $this->item = $item; } } class CT_Keyword { var $id_kw; var $nom; public function __construct($id, $name) { $this->id_kw = $id; $this->nom = $name; } } class AmeliuswsService { protected $doctrine; public function __construct(Registry $doctrine) { $this->doctrine = $doctrine; } public function getKeywords($ts, $sign) { $em = $this->doctrine->getEntityManager(); $kwl = $em->getRepository('AdpPageBundle:Keyword') ->findAll(); //$keywordList = new CT_KeywordsList(); foreach ($kwl as $kw) { $k = new CT_Keyword($kw->getId(), $kw->getKeyword()); $kwol = new CT_KeywordsList(); $kwol->addItem($k); $kwList[] = $kwol; } $return = array('ts'=>$ts, 'keywordList'=>$kwList, 'sign'=>$sign); return $return; } } ?>
résultat d'une requête avec SoapUI:
Code xml : 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 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http:/xxx" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns1:getKeywordsResponse> <ts>454212</ts> <keywordList> <SOAP-ENC:Struct> <item> <id_kw>1</id_kw> <nom>hello1</nom> </item> </SOAP-ENC:Struct> <SOAP-ENC:Struct> <item> <id_kw>2</id_kw> <nom>hello2</nom> </item> </SOAP-ENC:Struct> <SOAP-ENC:Struct> <item> <id_kw>3</id_kw> <nom>hello3</nom> </item> </SOAP-ENC:Struct> <SOAP-ENC:Struct> <item> <id_kw>4</id_kw> <nom>hello4</nom> </item> </SOAP-ENC:Struct> </keywordList> <sign>2455</sign> </ns1:getKeywordsResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Ci joint une capture de visual studio avec le contenant des variables.
Je situe le problème au niveau du code php, j'ai essayer de plusieurs façons (CT_KeywordsList contenant un tableau d'item, mais dans ce cas le serveur n'envoi qu'un seul element item contenant la totalité des items) mais aucune ne fonctionne.
Partager