You need to sign in to do that
Don't have an account?
Dscer
SOAP Message generates Invalid Session ID error
I am trying to run a query using the API by generating my own SOAP messages. I can login successfully but I get an Invalid Session ID when I run the query. I am using the ServerURL and SessionID generated by the login result in my query call. Below is a packet capture of my login call, response, query call and response. Any ideas?
POST /services/Soap/u/21.0 HTTP/1.1 Connection: Keep-Alive Content-Type: text/xml Accept: */* Accept-Language: en-us User-Agent: Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5) SOAPAction: "" Content-Length: 562 Host: test.salesforce.com <?xml version="1.0" encoding="UTF-8" standalone="no"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <mns:login xmlns:mns="urn:partner.soap.sforce.com"> <mns:username xsi:type="xsd:string">user@domain.com.test </mns:username> <mns:password xsi:type="xsd:string">PaSsWoRd </mns:password> </mns:login> </SOAP-ENV:Body> </SOAP-ENV:Envelope> ------------------------------------------------------------------------------------------------------------ HTTP/1.1 200 OK Server: Content-Type: text/xml; charset=utf-8 Date: Thu, 27 Jan 2011 15:16:51 GMT Content-Length: 1753 Connection: Keep-Alive <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <loginResponse> <result> <metadataServerUrl>https://tapp0-api.salesforce.com/services/Soap/m/21.0/00DT0000000**** </metadataServerUrl> <passwordExpired>false </passwordExpired> <sandbox>true </sandbox> <serverUrl>https://tapp0-api.salesforce.com/services/Soap/u/21.0/00DT0000000**** </serverUrl> <sessionId>00DT0000000****!AR8AQN********CatI6TXoKHzL8EAVFCRGd********yYwhAhbBFj4HehdoQW3********aBn11YgE3Jx********IUGeOft </sessionId> <userId>00520000000******* </userId> <userInfo> yada-yada </userInfo> </result> </loginResponse> </soapenv:Body> </soapenv:Envelope> ------------------------------------------------------------------------------------------------------------ POST /services/Soap/u/21.0/00DT0000000**** HTTP/1.1 Connection: Keep-Alive Content-Type: text/xml Accept: */* Accept-Language: en-us User-Agent: Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5) SOAPAction: "" Content-Length: 759 Host: tapp0-api.salesforce.com <?xml version="1.0" encoding="UTF-8" standalone="no"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header> <SessionHeader> <sessionId>00DT0000000****!AR8AQN********CatI6TXoKHzL8EAVFCRGd********yYwhAhbBFj4HehdoQW3********aBn11YgE3Jx********IUGeOft </sessionId> </SessionHeader> </SOAP-ENV:Header> <SOAP-ENV:Body> <mns:query xmlns:mns="urn:partner.soap.sforce.com"> <mns:queryString xsi:type="xsd:string">SELECT Id, Name, BillingStreet FROM Account WHERE Name LIKE 'Test%' </mns:queryString> </mns:query> </SOAP-ENV:Body> </SOAP-ENV:Envelope> ------------------------------------------------------------------------------------------------------------ HTTP/1.1 500 Internal Server Error Server: Content-Type: text/xml; charset=utf-8 Date: Thu, 27 Jan 2011 15:18:00 GMT Content-Length: 700 Connection: Keep-Alive <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <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>
Your SessionHeader elements are not in the right namespace (they appear to be un-namespaced), check the WSDL for the correct namespace.