IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

SoapServer et ComplexType [PHP 5.3]


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juin 2012
    Messages : 2
    Points : 5
    Points
    5
    Par défaut SoapServer et ComplexType
    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.
    Images attachées Images attachées  

  2. #2
    Futur Membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juin 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juin 2012
    Messages : 2
    Points : 5
    Points
    5
    Par défaut
    Bon, il m'a suffit d'envoyer mon code sur ce forum pour comprendre mon erreur, mon tout premier code fonctionnais bien en réalité il manquais juste un "s" a KeywordsList pour renvoyer les bonnes valeurs.

    (Une demi-journée de perdu)

    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
    <?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());
    			$keywordList->addItem($k);
    		}
    		$return = array('ts'=>$ts, 'keywordsList'=>$keywordList, 'sign'=>$sign);
     
    		return $return;
    	}
     
    }
     
    ?>

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Web Service][SOAP] récupérer les données d'un complexType
    Par Guybrush113 dans le forum Bibliothèques et frameworks
    Réponses: 16
    Dernier message: 26/08/2010, 16h07
  2. [Web Service][SOAP] complextype : SOAP-ERROR: Encoding: Violation of encoding
    Par maximep dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 02/04/2009, 11h32
  3. [XSD] faire un complexType
    Par sanchou dans le forum Valider
    Réponses: 4
    Dernier message: 25/06/2007, 15h13
  4. manipulation des params complextype
    Par Dev_info dans le forum Services Web
    Réponses: 4
    Dernier message: 20/05/2007, 13h59
  5. [XML Schema] ComplexType ou Element ?
    Par spidetra dans le forum Valider
    Réponses: 2
    Dernier message: 16/01/2006, 15h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo