• MuraliM
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies

Hi, I am getting the following error when I tried to make an API call using PHP. Following are the SOAP headers and responses and the PHP code I am using. Any help in this regard is highly appreciated.

 

Request Header:

 

POST /services/Soap/c/17.0/00D900000000z6c HTTP/1.1
Host: ap1-api.salesforce.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.0
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:enterprise.soap.sforce.com#query"
Content-Length: 767

 

 

Request Body:

 

 <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns2:sessionId>
00D900000000z6c!ASAAQPsfHNs3F21qTmJ.y32J4jaWzwXYe0TdDCmjrJ81lE.0_yrxpKnBMwJGLmotvyFudnBGQQj9fLZ.lJvdxq67XAErgnF3
</ns2:sessionId>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:query>
<param0 xsi:type="xsd:string">select FirstName, LastName from Contact</param0>
</ns1:query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

Response:

 

<soapenv:Envelope>
<soapenv:Body>
<soapenv:Fault>
<faultcode>sf:INVALID_SESSION_ID</faultcode>
<faultstring>
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
</faultstring>
<detail>
<sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault">
<sf:exceptionCode>INVALID_SESSION_ID</sf:exceptionCode>
<sf:exceptionMessage>
Invalid Session ID found in SessionHeader: Illegal Session
</sf:exceptionMessage>
</sf:UnexpectedErrorFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

 

 

 

Following is my PHP code.

 

$soapcli = new SoapClient("file:///D:/sfdcapi/enterprise.wsdl", array('trace' => true));

$result = $soapcli->login(array("username" => 'xyz@hotmail.com', "password" => 'xxxxxxx'));

 

 

$variables = get_object_vars($result);
$keys = array_keys($variables);

 $soapcli = new SoapClient(null, array('location' => $variables[$keys[0]]->serverUrl,
                                                         'uri'      => "urn:enterprise.soap.sforce.com",
                                                         'trace' => true));
      
//set the Headers of Soap Client.
 $header =  new SoapHeader('urn:sobject.enterprise.soap.sforce.com', "sessionId",                                                           $variables[$keys[0]]->sessionId);
 $qr = $soapcli->__soapCall("query", array("select FirstName, LastName from Contact"), null, $header);
 

 

 Thanks,

Murali

 

 

 

Hi, I am getting the following error when I tried to make an API call using PHP. Following are the SOAP headers and responses and the PHP code I am using. Any help in this regard is highly appreciated.

 

Request Header:

 

POST /services/Soap/c/17.0/00D900000000z6c HTTP/1.1
Host: ap1-api.salesforce.com
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.3.0
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:enterprise.soap.sforce.com#query"
Content-Length: 767

 

 

Request Body:

 

 <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns2:sessionId>
00D900000000z6c!ASAAQPsfHNs3F21qTmJ.y32J4jaWzwXYe0TdDCmjrJ81lE.0_yrxpKnBMwJGLmotvyFudnBGQQj9fLZ.lJvdxq67XAErgnF3
</ns2:sessionId>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:query>
<param0 xsi:type="xsd:string">select FirstName, LastName from Contact</param0>
</ns1:query>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

Response:

 

<soapenv:Envelope>
<soapenv:Body>
<soapenv:Fault>
<faultcode>sf:INVALID_SESSION_ID</faultcode>
<faultstring>
INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
</faultstring>
<detail>
<sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault">
<sf:exceptionCode>INVALID_SESSION_ID</sf:exceptionCode>
<sf:exceptionMessage>
Invalid Session ID found in SessionHeader: Illegal Session
</sf:exceptionMessage>
</sf:UnexpectedErrorFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

 

 

 

Following is my PHP code.

 

$soapcli = new SoapClient("file:///D:/sfdcapi/enterprise.wsdl", array('trace' => true));

$result = $soapcli->login(array("username" => 'xyz@hotmail.com', "password" => 'xxxxxxx'));

 

 

$variables = get_object_vars($result);
$keys = array_keys($variables);

 $soapcli = new SoapClient(null, array('location' => $variables[$keys[0]]->serverUrl,
                                                         'uri'      => "urn:enterprise.soap.sforce.com",
                                                         'trace' => true));
      
//set the Headers of Soap Client.
 $header =  new SoapHeader('urn:sobject.enterprise.soap.sforce.com', "sessionId",                                                           $variables[$keys[0]]->sessionId);
 $qr = $soapcli->__soapCall("query", array("select FirstName, LastName from Contact"), null, $header);
 

 

 Thanks,

Murali

 

 

 

I haven't had much luck getting SSO to work with my SAML assertion. Has anyone got this to work? If so, what does your saml response look like?  I signed my assertion and I believe everything is correct, yet the login history gives me "Failed: Assertion Invalid"

Any ideas?

Thank you.