Re: [SOAP] Re: PHP4 SOAP Request problem logging in to salesforce.com

From: Date: Wed, 26 Oct 2005 01:29:24 +0000
Subject: Re: [SOAP] Re: PHP4 SOAP Request problem logging in to salesforce.com
References: 1 2 3 4  Groups: php.soap 
Request: Send a blank email to php-soap+get-2034@lists.php.net to get a copy of this message
The result of setting the header as suggested gives the following, where the header contains the username and password, but not the body - so the same problem persists. In addition, the fourth argument to SOAP_Header produced error "Did not understand "MustUnderstand" header(s)" when set to 1 - so it was changed to 0. SOAP Request: <?xml version="1.0" encoding="UTF-8"?> <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/" xmlns:ns4="urn:partner.soap.sforce.com" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header> <ns4:SessionHeader SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="0"> <sessionId xsi:nil="true"/></ns4:SessionHeader> <ns4:CallOptions SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="0"> <client xsi:type="xsd:string">phpClient/1.0</client></ns4:CallOptions> <ns4:login SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="1"> <username xsi:type="xsd:string">my supplied username</username> <password xsi:type="xsd:string">my supplied password</password></ns4:login> </SOAP-ENV:Header> <SOAP-ENV:Body> <ns4:login xsi:nil="true"/> </SOAP-ENV:Body> </SOAP-ENV:Envelope> The login function used is as follows: function &login($username, $password) {
       $login =& new SOAP_Value('{urn:partner.soap.sforce.com}login',false,$v=array("username"=>$username, "password"=>$password));
       $header =& new SOAP_Header(
           '{urn:partner.soap.sforce.com}login',
           'Struct',
           array("username"=>$username, "password"=>$password),
           0);
       $this->addHeader($header);
       $request = array('login'=>$login);
       return $this->call('login', $request,
           array('namespace'=>'urn:partner.soap.sforce.com',
                           'soapaction'=>'',
                           'style'=>'document',
                           'use'=>'literal' ));
} Why are the username and password not being inserted into the body? Colin Goldberg ** <http://www.plezecall.com/ease-savings/pc.pl?pc=zp7C> Michael Rasmussen wrote:
On Tue, 25 Oct 2005 18:20:00 -0400, Colin Goldberg wrote:
WebService_SforceService_Soap.php, whose login function was as follows: function &login($username, $password) {
       $login =& new
SOAP_Value('{urn:partner.soap.sforce.com}login',false,$v=array("username"=>$username, "password"=>$password));
       return $this->call("login",
                       $v = array('login'=>$login),
                       array('namespace'=>'urn:partner.soap.sforce.com',
                           'soapaction'=>'',
                           'style'=>'document',
                           'use'=>'literal' ));
} }
This is wrong because authentication must be part of the header in every succeeding request from the client. To do that you add a new SOAP_Header to your client in which case your client will transmit this header as part of every request to the server.
and then: $request = array(....); (??) $response =& $client->call('login', $request, $namespace);
This was just to show you that requests for the various services provided by the server must be done after adding the header to the client


« previous php.soap (#2034) next »