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
hchhch 

Invalid Session ID found in SessionHeader: Illegal Session

Hi,

 I am facing problem with the integration of java with salesforce.

 

I have created a webservice class and generated wsdl for the same.When i am trying to call the webservice method in java it is showing the invalid session ID error.

 

CODE:

       HelloWebServiceLocator serLocator = new HelloWebServiceLocator ();

        PartnerConnection connection = null;
        ConnectorConfig partnerConfig  = new ConnectorConfig();
        partnerConfig .setUsername("*********************");
        partnerConfig .setPassword("************************");
        connection = Connector.newConnection(partnerConfig );

        serLocator.HelloWeb().sayHello();    //HelloWeb is the Apex Class & sayHello is the method

 

Here I am not passing sessionId.serLocator is not showing any default methods to set sessionID. How can I set session ID to the serLocator object? Can anyone provide me the sample code for this one?

 

dkadordkador

You need to set the Session header.  If you're using Axis, sample code can be found for it in our quickstart guide in the API documentation (http://www.salesforce.com/us/developer/docs/api/index.htm).

hchhch

I am not using axis tool. Through eclipse I have generated java classes. It generated 1 stub class, 2 proxy classes and 2 server classes. I am new to this integration part. I don't know how to set the session ID. Can you please share the sample code to set the session id?

dkadordkador

Based on the code you've already shown, you are using Axis.  Please look at the quickstart guide in the API documentation I linked to.

hchhch

Through the documents I am able to call the standard methods for Connection class. But i want to call the apex class which i have written through java. The consumed WSDL has generated the following classes:

1.HelloWebBindingStub

2.HelloWebPortType

3.HelloWebPortTypeProxy

4.HelloWebService

5.HelloWebServiceLocator

 

I am writing main class which is specified in my first post. HelloWebService (Interface)class is having the apex method which i want to call. Can you please suggest me the solution for this one?

 

Thanks in advance!!