function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jhilgemanjhilgeman 

PHP Toolkit 11 - Invalid SOAP Headers - describeSObject

I'm using the new 11.0 PHP Toolkit, connecting with the Enterprise client library. I log in, everything is working okay, and then I try to run:

$result = $connection->describeSObject("Organization");

It used to work fine in 1.0 and 1.1, but now it just fails every time. I used XDebug to trace it back, and here's the error:

PHP Fatal error:  SoapClient::__setSoapHeaders() [<a href='function.--setSoapHeaders'>function.--setSoapHeaders</a>]: Invalid SOAP header in /....yada yada.../11.0/soapclient/SforceBaseClient.php on line 250

I looked at that line, and it's just setting a SOAP header of "describeSObject" - not sure why it's failing. Any guesses or suggestions?
Tran ManTran Man
Can you print your soap request using this call?

Code:
echo $mySforceConnection->getLastRequest();

 



jhilgemanjhilgeman

I'm having a little trouble with that, since it is a fatal error and is exiting before I can run the next command. However, I did a few other things. First, I went into the BaseClient class and went to line 250, which is the following line in the setHeaders function:

Code:
$this->sforce->__setSoapHeaders($header_array);


 I ran the getLastRequest right before that line, and I got this output:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:enterprise.soap.sforce.com"><SOAP-ENV:Body><ns1:login><ns1:username>--- removed ---</ns1:username><ns1:password>--- also removed ---</ns1:password></ns1:login></SOAP-ENV:Body></SOAP-ENV:Envelope>

So it looks like this is the first command after logging in. My next step was to put a few more debugging lines into the BaseClient class to figure out what was going on. Here's the original setHeaders function:

Code:
private function setHeaders($call=NULL) {
        $this->sforce->__setSoapHeaders(NULL);
        $header_array = array (
        $this->sessionHeader
        );

        $header = $this->callOptions;
        if ($header != NULL) {
                array_push($header_array, $header);
        }

        if ($call == "create" ||
        $call == "merge" ||
        $call == "update" ||
        $call == "upsert"
        ) {
                $header = $this->assignmentRuleHeader;
                if ($header != NULL) {
                        array_push($header_array, $header);
                }
        }

        if ($call == "login") {
                $header = $this->loginScopeHeader;
                if ($header != NULL) {
                        array_push($header_array, $header);
                }
        }

        if ($call == "create" ||
        $call == "resetPassword" ||
        $call == "update" ||
        $call == "upsert"
        ) {
                $header = $this->emailHeader;
                if ($header != NULL) {
                        array_push($header_array, $header);
                }
        }


        if ($call == "create" ||
        $call == "merge" ||
        $call == "query" ||
        $call == "retrieve" ||
        $call == "update" ||
        $call == "upsert"
        ) {
                $header = $this->mruHeader;
                if ($header != NULL) {
                        array_push($header_array, $header);
                }
        }

        if ($call == "delete") {
                $header = $this->userTerritoryDeleteHeader;
                if ($header != NULL) {
                        array_push($header_array, $header);
                }
        }

        if ($call == "query" ||
        $call == "queryMore" ||
        $call == "retrieve") {
                $header = $this->queryHeader;
                if ($header != NULL) {
                        array_push($header_array, $header);
                }
        }
        $this->sforce->__setSoapHeaders($header_array);
}

 
I dumped the argument $call, which came out to be "describeSObject" (without quotes)
 
I then var_export()-ed the $header_array immediately above the last line of __setSoapHeaders($header_array) and I got an array with a single null value:
 
array(0 => NULL)
 
I'm guessing that setting the SOAP headers to an array containing nothing but a null is probably the issue, but I don't know for sure. We're using PHP 5.1.2.
 
- Jonathan
 
jhilgemanjhilgeman
Think I have it solved.
 
I ended up creating a separate script that wasn't tied into the rest of the application, and tested the describeSObject call and it looks like the problem was that we weren't supposed to be using the Enterprise client class.
 
We changed back to the Partner client class, and thanks to Nick Tran, we got the updated code to implement the client ID so we could connect and log in properly. Here's the link to the other thread that had the correct Partner login code:
 
 
After logging in successfully with the normal client ID, I could run a describeSObject call and it ran just fine.