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

Bibliothèques et frameworks PHP Discussion :

[Web Service] WSDL soapHeader PHP authentification


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    52
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 52
    Points : 45
    Points
    45
    Par défaut [Web Service] WSDL soapHeader PHP authentification
    Bonjour
    je souhaite développer un web service en SOAP.
    Je dois passer des paramètres de login et de mdp dans le header, ce que je fais, mais le pb est que je n'arrive pas à les récuperer du cote serveur (de fais ma WS me renvoie toujours false quelque soit la valeur passé).
    Alors le pb pourrais se trouver du cote du fichier WSDL.
    Ce que je souhaitais savoir, c'est si la méthode qui permet l'authentification cote serveur dois se trouver dans le fichier WSDL, et dans ce cas, si celle méthode dois avoir un "code spéciale " dans le wsdl.

    Voici mon code qui toutefois reste dans ce qu'on trouve sur le web.

    Cote Client :
    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
     
    class UserPasswordPair
    {
        public $Username;
        public $Password;
     
        function __construct($Username, $Password)
        {
            $this->Username = $Username;
            $this->Password = $Password;
        }
    }
    $credentials = new UserPasswordPair("test", "test");
     
    $soapAuthenticator = new SoapVar(
    $credentials,
    SOAP_ENC_OBJECT,
    "headerAuthentify");
     
    $authHeader = new SoapHeader("http://127.0.0.1/clientTest/","headerAuthentify",$soapAuthenticator,false);
     
    try 
    {	
    	$client = new SoapClient( 'http://127.0.0.1/clientTest/fiche.wsdl', array ('trace'=>true));
    	$InfoResponse = $client->__soapCall("getServerInfo",array(),NULL,$authHeader);

    Cote Serveur :
    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
     
     
    class mySoapClass {
     
        public $passed;
    	public $use;
    	public $pass;
     
        public function headerAuthentify( $parameters){
     
        	$this->use = $parameters;
        	$this->pass = $NewPart;
     
            if($parameters =="test"){
                $this->passed = true;
            } else {
                $this->mySoapErr( );
            }
        }
     
    	public function mySoapErr(){
          print "Erreur";
        }
     
        public function getServerInfo(){
    		$this->headerAuthentify( $username, $password );
            if(!$this->passed){
                 return array('info' => 'Inconnu : '.$this->use);
            }
    		 return array('info' => 'ok');
        }
     
    }
     
    $server = new SoapServer('http://127.0.0.1/clientTest/fiche.wsdl',  array('trace' => 1, 'soap_version' => SOAP_1_2));
    $server -> setclass('mySoapClass');
     
    	$server->handle();
    Cote wsdl :

    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
     
     
    <?xml version="1.0"?>
     
    <definitions name="CSP"
        targetNamespace="urn:CSP"
        xmlns:tns="urn:CSP"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
        xmlns:typens="urn:CSP"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        xmlns="http://schemas.xmlsoap.org/wsdl/">
     
    <types>
        <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:CSP"> 
            <xsd:complexType name="MyInfo">
                <xsd:all>
                    <xsd:element name="info" type="xsd:string"/>
                </xsd:all>
            </xsd:complexType>
        </xsd:schema>
    </types>
     
    <message name="getServerInfo">
        <part name="none" type="xsd:int"/>
    </message>
    <message name="getServerInfoResponse">
        <part name="value" type="typens:MyInfo"/>
    </message>
     
    <portType name="CspPorts">
        <operation name="getServerInfo">
            <input  message="getServerInfo"/>
            <output message="getServerInfoResponse"/>
        </operation>
    </portType>
     
    <binding name="MyBinding"  type="typens:CspPorts">
        <soap:binding style="rpc" 
            transport="http://schemas.xmlsoap.org/soap/http" />
          <operation name="getServerInfo">
              <soap:operation
                 soapAction="http://127.0.0.1/clientTest/fiche.wsdl"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>
    <service name="MyWebService">
        <documentation>Mon Service web</documentation>
            <port name="CspPorts" binding="typens:MyBinding">
          <soap:address location="http://127.0.0.1/clientTest/test.php"/>
        </port>
      </service>
     
    </definitions>
    Merci

  2. #2
    Membre du Club
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    52
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 52
    Points : 45
    Points
    45
    Par défaut
    Voila la reponse
    elle se trouve dans la discussion
    http://php.net/manual/en/soapheader.soapheader.php

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

Discussions similaires

  1. [Web Service][SOAP] Débutant PHP/NuSOAP
    Par tintin72 dans le forum Bibliothèques et frameworks
    Réponses: 9
    Dernier message: 20/02/2014, 21h17
  2. [Web Service][SOAP] client php et web service windev
    Par pev15 dans le forum Bibliothèques et frameworks
    Réponses: 7
    Dernier message: 28/05/2010, 13h48
  3. [Web Service][SOAP] Problème d'authentification
    Par Maelenkolix dans le forum Bibliothèques et frameworks
    Réponses: 8
    Dernier message: 13/08/2009, 08h55
  4. [Web Service] wsdl axis -> servlet
    Par Delwyn dans le forum Services Web
    Réponses: 5
    Dernier message: 20/03/2008, 13h01
  5. [Web Service][SOAP] Tableau php et type complexe ?
    Par tintin72 dans le forum Bibliothèques et frameworks
    Réponses: 4
    Dernier message: 18/06/2007, 11h31

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