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
eneilseneneilsen 

I'm trying to set the sessionId without using the SessionHeader object

I'm trying to set the sessionId without using the SessionHeader object. This is the error that I'm getting:

Code:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.getSOAPFaultException(SOAPFaultHelperJAXWS.java:56)
 at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.throwFaultException(SOAP11BindingJAXWS.java:111)
 at org.jboss.ws.core.CommonSOAPBinding.unbindResponseMessage(CommonSOAPBinding.java:460)
 at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:333)
 at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:185)
 at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:163)
 at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:149)
 at $Proxy22.query(Unknown Source)
 at salesforce.JbossWSConnection.querySample(JbossWSConnection.java:130)
 at salesforce.JbossWSConnection.main(JbossWSConnection.java:74)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

 
Does anyone know what the Parameter Name is used to include the sesssionID?  Is it SessionID, sessionID, SessionHeader?
SuperfellSuperfell
Here's an example soap message that shows the sessionHeader structure.
http://wiki.apexdevnet.com/index.php/Enterprise_Describe_Global
eneilseneneilsen
Thanks
MilanMilan
Here is some code..
Code:
Initially :

URL enterLoginURL = new URL(ApexConstants.entrLoginURL);
   stub = new SforceService(enterLoginURL, null);



protected void initialize(String serverURL, String sessionID)
   throws MessagingException {
  try {
   
   /**
    * Once the client application has logged in successfully, it will
    * use the results of the login call to reset the endpoint of the
    * service to the virtual server instance that is servicing your
    * organization. To do this, the client application sets the
    * ENDPOINT_ADDRESS_PROPERTY of the binding object using the URL
    * returned from the LoginResult.
    */
   /*stub._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,
     serverURL);
        
   /**
    * The client application now has an instance of the SoapBindingStub
    * that is pointing to the correct endpoint. Next, the client
    * application sets a persistent SOAP header (to be included on all
    * subsequent calls that are made with the SoapBindingStub) that
    * contains the valid sessionId for our login credentials. To do
    * this, the sample client application creates a new SessionHeader
    * object and set its sessionId property to the sessionId property
    * from the LoginResult object.
    */
   // Create a new session header object and add the session id
   // from the login return object
   SessionHeader sh = new SessionHeader();
   sh.setSessionId(sessionID);
   /**
    * Next, the client application calls the setHeader method of the
    * SoapBindingStub to add the header to all subsequent method calls.
    * This header will persist until the SoapBindingStub is destroyed
    * until the header is explicitly removed. The "SessionHeader"
    * parameter is the name of the header to be added.
    */
   // set the session header for subsequent call authentication
   stub.setHeader(new SforceServiceLocator().getServiceName()
     .getNamespaceURI(), "SessionHeader", sh);

  } catch (AxisFault af) {
   af.printStackTrace();
  } catch (MalformedURLException e) {
   e.printStackTrace();
  }
  if (stub != null) {
   initialized = true;
  }
 }

 
Maybe this is useful.
 
Milan