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
junaid_ajjunaid_aj 

InValid Session Id

I am able to connect to Dev Org and can Create Account Object,but when i try to invoke my Webservice Class i am getting following Error.
I had searched in forums also but no help.

AxisFault
 faultCode: {http://soap.sforce.com/schemas/class/WebserviceActivityData}INVALID_SESSION_ID
 faultSubcode:
 faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session
 faultActor:
 faultNode:
 faultDetail:

The Code for Invoking is:

private boolean login() {
        WebserviceActivityDataService ws = new WebserviceActivityDataServiceLocator();
        SessionHeader sh = new SessionHeader();
        WebserviceActivityDataPortType por = null;
        try {           
           
            binding = (WebserviceActivityDataBindingStub) new WebserviceActivityDataServiceLocator()
                    .getSoap();           
            // Time out after a minute
            binding.setTimeout(600000);
            loginResult = binding.login(un, pw);

            sh.setSessionId(loginResult.getSessionId());
            System.out.println(sh.getSessionId());
            System.out.println(ws.getServiceName().getNamespaceURI());
            binding.setHeader(ws.getServiceName().getNamespaceURI(), "SessionHeader", sh);

            por = ws.getWebserviceActivityData();
            por.saveCO2();

        } catch (ServiceException ex) {
            System.out
                    .println("ERROR: creating binding to soap service, error was: \n"
                            + ex.getMessage());
            return false;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

Please help.

I have generated Java File from WSDL of the Class.

Regards,
Mohammed Junaid.
AaronZhangAaronZhang
The same as me. Anyone can help?