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

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

 



On Wed, 26 Oct 2005 21:19:25 -0400, Colin Goldberg wrote:

> Taking your code as-is, I get the error: "curl_exec error 60 error setting
> certificate verify locations". I think I have to set the curl
> CURLOPT_CAINFO option to point to a certificate file, but I am not sure
> where in the SOAP file hierarchy the curl function is available.
>
Correct. The login function requires that php-curl is installed and
enabled because the action specifies that the request must use https.
What distro are you using? On my Debian it was just apt-get install
php5.0-curl and then it worked out-of-the-box.

> But a View Source shows me that the username and password were inserted
> into the SOAP body.
> 
Jep, after looking at the WSDL I found out that the are using I none
standard way of doing login or perhaps the are using some kind of session
feature outside of SOAP. The prescribed way of handling this issue is to
add it to the header of every SOAP request.

An example server could look like this:
<?php
// authServer.php
require_once 'SOAP/Server.php';

// The handler of SOAP headers
class Header_Handler {
    var $method_namespace = 'urn:AuthHandler';
    var $authenticated = FALSE;

    function authenticate($authinfo)
    {
        if ($authinfo->username == 'foo' &&
            $authinfo->password == 'bar') {
            $this->authenticated = TRUE;
            return 'Authentication OK';
        }
        $faultcode = 'Client';
        $faultstring = 'Invalid Authentication';
        $faultactor = $this->method_namespace;
        $detail = NULL;
        return new SOAP_Fault($faultstring,
                              $faultcode,
                              $faultactor,
                              $detail);
    }
}

// The class server
class Simple_Server {
    var $method_namespace = 'urn:AuthServer';

    function Simple_Server() {
        global $server;
        $this->headers = new Header_Handler();
        $server->addObjectMap($this->headers, 'urn:AuthHandler');
    }

    function echoString($text) {
        if (!$this->headers->authenticated) {
            $faultcode = 'Client';
            $faultstring = 'You must send authentication headers';
            $faultactor = $this->method_namespace;
            $detail = NULL;
            return new SOAP_Fault($faultstring,
                                  $faultcode,
                                  $faultactor,
        }
        return $text;
    }
}

$server = new SOAP_Server;
$myserver = new Simple_Server();
$server->addObjectMap($myserver, 'urn:AuthServer');
$server->service($HTTP_RAW_POST_DATA);
?>


-- 
Hilsen/Regards
Michael Rasmussen
http://keyserver.veridis.com:11371/pks/lookup?op=get&search=0xE3E80917

-- 
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