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] soap header authentification


Sujet :

Bibliothèques et frameworks PHP

  1. #1
    Membre averti

    Femme Profil pro
    Inscrit en
    Août 2003
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Sénégal

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2003
    Messages : 16
    Par défaut [Web Service] soap header authentification
    Bonjour
    J essaye vainement de m'authentifier en envoyant un header a un service Soap , la classe serveur n entre jamais dans la methode header
    Quel qu un peut il m aider .
    Voici mon script 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
    26
    27
    28
    29
    30
    31
    32
    33
    34
     
    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://schemas.xmlsoap.org/ws/2002/07/utility","headerAuthentify",$soapAuthenticator,false);
     
    try 
    {	
    $client = new SoapClient( 'fiche.wsdl', array ('trace'=>true));
    $InfoResponse = $client->__soapCall(
    "getServerInfo",array(),NULL,$authHeader);										 
       $call = $client->__call('getServerInfo',array());	
      echo $call->info;
    }
     
    catch (SoapFault $exception)
    {
    	print($exception);
    }
    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
    class mySoapClass {
        public $passed;
     
        public function headerAuthentify( $username, $password ){
     
            if($username =="test"){
                $this->passed = true;
            } else {
                $this->mySoapErr( );
            }
        }
     
    	public function mySoapErr(  ){
          print "Erreur";
        }
        public function getServerInfo(){
     
            if(!$this->passed){
                 return array('info' => 'Inconnu'.$this->login);
            }
    		 return array('info' => 'ok');
        }
     
    }
     
    try {
        $server = new SoapServer('fiche.wsdl',  array('trace' => 1, 'soap_version' => SOAP_1_1));
        // On définit la classe qui va gérer les requètes SOAP
        $server -> setclass('mySoapClass');
    } catch (Exception $e) {
        echo $e;
    }
    et enfin ma fiche 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
    <?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:8080/security/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:8080/security/server.php"/>
        </port>
      </service>
     
    </definitions>

  2. #2
    Membre averti

    Femme Profil pro
    Inscrit en
    Août 2003
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Sénégal

    Informations professionnelles :
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Août 2003
    Messages : 16
    Par défaut

    c 'est ok en fait j avais oublié de rajouter la definition de ma methode headerAuthentify dans mon fichier wsdl

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

    Informations forums :
    Inscription : Janvier 2008
    Messages : 52
    Par défaut
    Salut
    on pourrait avoir la définition du headerAuthentify dans le fichier wsdl
    car le soucis c'ets que j'ai
    Notice: Trying to get property of non-object in C:\Program Files\EasyPHP-5.3.3\www\clientTest\Client.php on line 27

    comme erreur

    Merci bien

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

Discussions similaires

  1. web service - soap security header - binding configuration
    Par Tiwaz dans le forum Services Web
    Réponses: 1
    Dernier message: 26/12/2013, 10h35
  2. [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
  3. [Web Service][SOAP] Exception 'Error Fetching http headers' aléatoirement
    Par arnolem dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 25/06/2009, 15h54
  4. [Web Service][SOAP] WebService : problème d'authentification
    Par SuperGilou dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 11/06/2007, 15h16
  5. [Web Service][SOAP] PHP5 SOAP et header
    Par ckeromen dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 18/12/2006, 20h27

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