PHP4 SOAP Request problem logging in to salesforce.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Using PHP4/Pear/SOAP with Apache/Linux, I am having trouble with a login request to salesforce.com that I do not understand. Instead of username and password appearing in the request, there is:

<ns4:login xsi:nil="true"/>


Taking an open source example - php-client (http://sourceforge.net/project/showfiles.php?group_id=96634&package_id=104202) - (almost) out of the box, with a minor modification to use a wsdl file, the relevant code goes like this:

File login.php:
require_once("../SalesforceClient.php");

$client = new SalesforceClient();
$result = $client->login($_REQUEST['username'],$_REQUEST['password']);
if (PEAR::isError($result)) {
 $errors = "Error: " . $result->getMessage() . "\n";
} else {
// success!
}

File SalesforceClient.php:
require_once("WebService_SforceService_Soap.php");

class SalesforceClient extends WebService_SforceService_Soap
{
   var $sessionId;
function SalesforceClient($sessionId = null) { ... $this->WebService_SforceService_Soap();
   ...
 }
...
}

File WebService_SforceService_Soap.php:
require_once 'SOAP/Client.php';

class WebService_SforceService_Soap extends SOAP_Client
{
   function WebService_SforceService_Soap() {
     $wsdl_url = "http://my/url/for/sforce_partner.wsdl";;
     $this->SOAP_Client($wsdl_url , true);
   }
   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' ));
   }
...

I have a valid salesforce.com developer login, and I am using the partner API. The wsdl file was downloaded from salesforce.com.

Here is the actual 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>
</SOAP-ENV:Header>
<SOAP-ENV:Body>

<ns4:login xsi:nil="true"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

A print_r of the login object before the call shows the values:
login=Array
(
   [login] => soap_value Object
       (
           [value] => Array
               (
                   [username] => [my valid username]
                   [password] => [my valid password]
               )

           [name] => login
[type] => [namespace] => urn:partner.soap.sforce.com
...
}

Can you help me discover why parameters username and password do not appear in the request?

Many thanks.

Colin Goldberg

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux