You need to sign in to do that
Don't have an account?
meister.eder
Apache CXF: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
hey guys,
i have the following problem:
private Soap salesforceClient; private SessionHeader sh; private HashSet<Login> loginSet; public void init() { try { if(salesforceClient == null){ SforceService ss = new SforceService(new URL("link/to/enterprise.wsdl"), new QName("urn:enterprise.soap.sforce.com", "SforceService")); salesforceClient = ss.getSoap(); LoginResult loginResult = salesforceClient.login("LOGIN", "PASSWORD+TOKEN"); ((BindingProvider) salesforceClient).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl()); //ss.addPort(portName, loginResult.getSessionId(), loginResult.getMetadataServerUrl()) //Create a new session header object and set the session id to that returned by the login sh = new SessionHeader(); sh.setSessionId(loginResult.getSessionId()); } } catch (InvalidIdFault_Exception e) { logger.debug(e.toString()); } catch (LoginFault_Exception e) { logger.debug(e.toString()); } catch (UnexpectedErrorFault_Exception e) { logger.debug(e.toString()); } catch (MalformedURLException e) { logger.debug(e.toString()); e.printStackTrace(); } }
I get the UnexpectedErrorFault_Exception INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
You've logged in, created the SessionHeader, set the sessionId to the SessionHeader, but you never set the SessionHeader back to the SforceService. Do that.
Ok, but can you explain how to set the SessionHeader back to the sf service ?
This question is answered in the CXF FAQ.
Another method is to use the -exsh true argument when running wsdl2java. This flag will add all binding inputs to your port stub. For example, instead of calling portStub.query(soql), you would have a method such as portStub.query(sessionHeader, soql)