**UPDATE**

I created the below answer which allows you to use a REST application connection to (from there on) work on the SOAP API without needing to use SOAP's `Login` method, but instead relies completely on access\_token and REST generated URLS to work. 

**/UPDATE**

Hey guys I'm trying to switch gears from REST to SOAP after finding that the RESTful API isn't flexible enough to do exactly what I need to do with it, I am currently trying to migrate a few things into the SOAP request to get this going but am running up against a wall.

I currently have users authorizing an application via REST, and returning Bearer and Access tokens, the step to use those (and the Location URL) are evading me though. I'm hoping that I can use my initial REST request to fuel my SOAP api.

This would mean that there is NO Username/Password sequence from here on!

I've been trying to implement multiple things that I've seen in the Java service, but it looks like they aren't supported in the PHP distro? Here's the code, maybe someone can point me in the right direction.

```
<?php 
// clear wsdl cache
ini_set("soap.wsdl_cache_enabled", 0);
?>

<pre>
<?php
    define("SOAP_CLIENT_BASEDIR",   'soapclient');

#    define("SF_USERNAME",           'foo@foodomain.com');
#    define("SF_PASSWORD",           'password');
#    define("SF_SECURITY",           ''); // shouldn't be needed after Auth Bearer

#    define("SF_LOCATION",           'https://na15-api.salesforce.com/services/Soap/u/27.0/?????');
#    define("SF_SESSIONID",          '??????');

    define("SF_LOGINURL",         'http://login.salesforce.com');

require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');

try {

/**
 *   This section should theoretically be taken over by REST Auth Bearer
 *   so we do not need to use a U/P sequence for clients after accepting 
 *   our application.
 *
 *   $mySforceConnection = new SforcePartnerClient();
 *   $mySoapClient       = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');
 *   $loginResult        = $mySforceConnection->login(SF_USERNAME, SF_PASSWORD.SF_SECURITY);
 *
 *   $location    = $mySforceConnection->getLocation();
 *   $sessionId   = $mySforceConnection->getSessionId();
 */

    $mySforceConnection     = new SforcePartnerClient();
    $sforceSoapClient       = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner.wsdl.xml');

        // broken; is not available in PHP distro ??
        $mySforceConnection->setAuthEndpoint(SF_LOGINURL);      // does not exist....
        $mySforceConnection->setServiceEndpoint(SF_LOGINURL);   // does not exist....
        $mySforceConnection->setManualLogin(TRUE);              // does not exist....

    // try
    $globals = $mySforceConnection->describeGlobal();

    $query = "SELECT Id,Name FROM User";
    $response = $mySforceConnection->query($query);
    #    $queryResult = new QueryResult($response);
    #    print_r($queryResult);

    $sObject = new SObject($response->records[0]);
    print_r($sObject);

    /** Expected Output:
     *  Should be as follows

        SObject Object
        (
            [type] => User
            [fields] => stdClass Object
                (
                    [Id]    => ?????
                    [Name]  => foo bar 
                )
        )
    */

} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}

```