You need to sign in to do that
Don't have an account?
Invalid Session ID Error at binding.create
Hi,
ISSUE :
We are using Intershop Infinity as our App Server and We have successfully created the SoAP client. We Are able to successfully login to SF server. However we are encountering the following error of Invalid Session ID
Error Excerpt :
appserver0: An exception occured invoking service login().
appserver0: AxisFault
appserver0: faultCode: {urn:fault.enterprise.soap.sforce.com}INVALID_SESSION_ID
appserver0: faultSubcode:
appserver0: faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
appserver0: faultActor:
appserver0: faultNode:
appserver0: faultDetail:
appserver0: {urn:fault.enterprise.soap.sforce.com}UnexpectedErrorFault: <ns1:exceptionCode>INVALID_SESSION_ID</ns1:exceptionCode><ns1:exceptionMessage>Invalid Session ID found in SessionHeader: Illegal Session</ns1:exceptionMessage>
appserver0:
appserver0: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
appserver0: at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
appserver0: at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
appserver0: at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
appserver0: at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
appserver0: at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
appserver0: at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
appserver0: at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
appserver0: at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
appserver0: at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
appserver0: at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
appserver0: at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
appserver0: at javax.xml.parsers.SAXParser.parse(Unknown Source)
appserver0: at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
appserver0: at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
appserver0: at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
appserver0: at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:675)
appserver0: at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:128)
appserver0: at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
appserver0: at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
appserver0: at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
appserver0: at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
appserver0: at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
appserver0: at org.apache.axis.client.Call.invoke(Call.java:2553)
CODE EXCERPT :
Soap service = (new SforceServiceLocator()).getSoap();
// LoginResult loginResult = service.login(username, password);
SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
binding.setTimeout(600000);
LoginResult loginResult = binding.login(username, password);
System.out.println("serviceResult....." + loginResult.getServerUrl());
// Create a new session header object and set the
// session id to that returned by the login
binding._setProperty(
SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getServerUrl());
// Create a new session header object and set the session id to that
// returned by the login
SessionHeader sh = new SessionHeader();
System.out.println("Server ID: " + loginResult.getSessionId());
System.out.println("Service name:" + new SforceServiceLocator().getServiceName());
//sh.setSessionId(loginResult.getSessionId());
binding.setHeader(
new SforceServiceLocator().getServiceName().getNamespaceURI(),
"SessionHeader",
sh);
System.out.println("SH SESS ID: " +sh.getSessionId());
//*****************************************************************
Contact contact;
SObject[] cons = new Contact[2];
System.out.println("create called....3");
for (int j = 0; j < 2; j++) {
contact = new Contact();
System.out.println("In loop...");
contact.setAssistantName("Jane");
contact.setAssistantPhone("777.777.7777");
contact.setDepartment("Purchasing");
contact.setDescription("International IT Purchaser");
contact.setEmail("joeblow@isp.com");
contact.setFax("555.555.5555");
contact.setMailingCity("San Mateo");
contact.setMailingCountry("US");
contact.setMailingState("CA");
contact.setMailingStreet("1129 B Street");
contact.setMailingPostalCode("94105");
contact.setMobilePhone("888.888.8888");
contact.setFirstName("Joe");
contact.setLastName("Blow");
contact.setSalutation("Mr.");
contact.setPhone("999.999.9999");
contact.setTitle("Purchasing Director");
cons[j] = contact;
}
System.out.println("Cons length: "+cons.length);
<<ERROR LINE>> SaveResult[] sr = binding.create(cons); <<ERROR LINE>>
for (int j = 0; j < sr.length; j++) {
if (sr[j].isSuccess()) {
System.out.println("A contact was created with an id of: "
+ sr[j].getId());
}
}
Please Advise.
Thanks
Saachin,
In our code the set session ID is Uncommented..
sh.setSessionId(loginResult.getSessionId());
But still the problem persists..
Regards,
Saachin
Hi,
ISSUE :
We are using Intershop Infinity as our App Server and We had created the SoAP client. We are able to successfully login to SF server. However we are encountering the following error of Invalid Session ID in the same line as mentioned above code excerpt
Error Excerpt :
appserver0: An exception occured invoking service login().
appserver0: AxisFault
appserver0: faultCode: {urn:fault.enterprise.soap.sforce.com}INVALID_SESSION_ID
appserver0: faultSubcode:
appserver0: faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
appserver0: faultActor:
appserver0: faultNode:
appserver0: faultDetail:
appserver0: {urn:fault.enterprise.soap.sforce.com}UnexpectedErrorFault: <ns1:exceptionCode>INVALID_SESSION_ID</ns1:exceptionCode><ns1:exceptionMessage>Invalid Session ID found in SessionHeader: Illegal Session</ns1:exceptionMessage>
appserver0:
appserver0: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
appserver0: at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:260)
appserver0: at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:169)
appserver0: at org.apache.axis.encoding.DeserializationContextImpl.endElement(DeserializationContextImpl.java:1015)
appserver0: at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
appserver0: at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
appserver0: at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
appserver0: at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
appserver0: at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
appserver0: at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
appserver0: at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
appserver0: at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
appserver0: at javax.xml.parsers.SAXParser.parse(Unknown Source)
appserver0: at org.apache.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:242)
appserver0: at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:538)
appserver0: at org.apache.axis.Message.getSOAPEnvelope(Message.java:376)
appserver0: at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:675)
appserver0: at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:128)
appserver0: at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
appserver0: at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
appserver0: at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
appserver0: at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
appserver0: at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
appserver0: at org.apache.axis.client.Call.invoke(Call.java:2553)
com.sforce.soap.enterprise
to see if you can locate this class:
SessionHeaderDocument
Hi,
There is no file named SessionHeaderDocument generated in the package com.sforce.soap.enterprise
Regards,
Saachin Ahuja
Hi,
The server session Id after invoking :
loginResult.getSessionId() gives:
00D90000000H143!AQ0AQGcxi6LkiVN5Z6SqIq2AdGtfGRR3TnsgTdR.8_jdsij3ATtNmO2iBVRWvWvqpGieBBNMQyl5qvGqHS_9cpz9dU.KDiAT
Regards,
SaachinAhuja
Following is the code snippet which we are using to connect with the sales force stubs:
package com.webaccommodate.enfinity.LSS.pipelet;
import com.intershop.beehive.core.capi.pipeline.Pipelet;
import com.intershop.beehive.core.capi.pipeline.PipelineDictionary;
import com.intershop.beehive.core.capi.pipeline.PipeletExecutionException;
import com.sforce.soap.enterprise.LoginResult;
import com.sforce.soap.enterprise.SaveResult;
import com.sforce.soap.enterprise.SessionHeader;
import com.sforce.soap.enterprise.SforceServiceLocator;
import com.sforce.soap.enterprise.Soap;
import com.sforce.soap.enterprise.SoapBindingStub;
import com.sforce.soap.enterprise.sobject.Account;
import com.sforce.soap.enterprise.sobject.Contact;
import com.sforce.soap.enterprise.sobject.SObject;
import javax.xml.rpc.ServiceException;
import java.net.URL;
import java.rmi.RemoteException;
/**
* Login to the Salesforce.com SOAP Api
*/
public class LoginNew extends Pipelet {String nextLoginTime;
String sessionId;
String serverUrl;
// lookup 'password' in pipeline dictionary
String password = "saachin1q6tWQri8eU0A37Ykz7SgwTddT";// lookup 'username' in pipeline dictionary
String username = "saachinahuja@gmail.com";try {Soap service = (
new SforceServiceLocator()).getSoap();binding.setTimeout(6000000);
LoginResult loginResult = binding.login(username, password);
System.out.println("serviceResult....." + loginResult.getServerUrl()); System.out.println("USERID::: " + loginResult.getUserId());// Create a new session header object and set the
// session id to that returned by the login
binding._setProperty(
SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
loginResult.getServerUrl());
// Create a new session header object and set the session id to that
// returned by the login
SessionHeader sh = new SessionHeader();String sessID = loginResult.getSessionId();
System.out.println("Seesion ID: " + sessID);System.out.println("Service name:" + new SforceServiceLocator().getServiceName());sh.setSessionId(sessID);
binding.setHeader(
new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader",sh);
System.out.println("SH SESS ID: " + sh.getSessionId());//*****************************************************************
Contact contact;
SObject[] cons = new Contact[2];for (int j = 0; j < 2; j++) {contact =
new Contact();System.out.println("In loop...");contact.setAssistantName(
"Jane");contact.setAssistantPhone("777.777.7777");contact.setDepartment(
"Purchasing");contact.setDescription("International IT Purchaser");contact.setEmail(
"joeblow@isp.com");contact.setFax("555.555.5555");contact.setMailingCity(
"San Mateo");contact.setMailingCountry("US");contact.setMailingState(
"CA");contact.setMailingStreet("1129 B Street");contact.setMailingPostalCode(
"94105");contact.setMobilePhone("888.888.8888");contact.setFirstName(
"Joe");contact.setLastName("Blow");contact.setSalutation(
"Mr.");contact.setPhone("999.999.9999");contact.setTitle(
"Purchasing Director");cons[j] = contact;
}
System.out.println("Cons length: " + cons.length);SaveResult[] sr = binding.create(cons);
for (int j = 0; j < sr.length; j++) {if (sr[j].isSuccess()) {System.out.println(
"A contact was created with an id of: " + sr[j].getId());}
}
//*****************************************************************
dict.put("sessionID", loginResult.getSessionId());// store 'Result' in pipeline dictionary
dict.put("loginResult", loginResult);dict.put("binding", binding);}
catch (ServiceException e) {throw new PipeletExecutionException(
"Could not bind to service com.webaccommodate.enfinity.LSS.Sforce.Soap.",e);
} catch (RemoteException e) {throw new PipeletExecutionException(
"An exception occured invoking service login().",e);
} catch (Exception e) {throw new PipeletExecutionException(
"An exception occured invoking service login().",e);
}
return PIPELET_NEXT;}
}
Regards,
saachin ahuja
Which host address is your service pointing to? The reason why i am asking this is because, i cannot see your ServiceStub bind to a salesforce service host as shown below:
private URL host = new URL("https://www.salesforce.com/services/Soap/u/10.0");
* This method is used to log in to salesforce and set the
* private class variables for the wrapper, including the
* session ID.
*/
public void login() throws UnexpectedErrorFault, InvalidIdFault, LoginFault, RemoteException, ServiceException {
resetBindingStub();
LoginResult loginResult = binding.login(username, password);
this.nextLoginTime = System.currentTimeMillis() + (this.sessionlength * 60000);
this.binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());
this.sessionId = loginResult.getSessionId();
this.serverUrl = loginResult.getServerUrl();
// Create a new session header object and set the
// session id to that returned by the login
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
this.binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);
}
/** This method resets the binding object back to its
* initial state.
*/
private void resetBindingStub() throws ServiceException {
this.binding = (SoapBindingStub) new SforceServiceLocator().getSoap(this.host);
this.binding.setTimeout(60000);
setCompressionOnBinding();
this.assignmentRules = null;
this.queryOptions = null;
}
Hi,
We have tried all the proposed solutions but the same exception still persists.
Kindly Help!!!
Regards,
Saachin Ahuja
Download the Quick Start Source and try and execute it on your enviroment to see if it does work, Ideally if you still have this issue then make sure you have httpmonitor, to monitor the SOAP message between your appserver and salesforce. Sometimes but rearly your appserver can be assign invalid value.
Hello,
Java quick start follows jdk1.5 version and we are using jdk1.3 with the server Intershop Enfinity .We need to find a solution in this environment itself.We tried to test the wsdl thro soapUI testing tool and it works.
Kindly rectify if there is any thing wrong in the code or the approach.
Regards,
Saachin Ahuja