+ Start a Discussion
Arvind1Arvind1 

Webservice callout error: Invalid Session ID found in SessionHeader

Hi All,

 

I am a newbie to webservice. So just tried to create my first webservice.

 

I created the helloworld webservice class in one salesforce instance. I generated wsdl file from that.

 

I parsed this wsdl file to generate an apex class in another salesforce instance. I wrote a trigger and called an apex class

 

In the apex class I called the stub class of the parsed apex class. But I am getting the following error:

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=

 Following is the code of my apex class:

 

public class testwebser{ @future(callout=true) public static void webmethod(Id aa){ String strAuthorizationHeader, strUserName,strPassword; Blob blbHeaderValue; soapSforceComSchemasClassHelloworld.HelloWorldWebService hwb = new soapSforceComSchemasClassHelloworld.HelloWorldWebService(); soapSforceComSchemasClassHelloworld.SessionHeader_element objSession = new soapSforceComSchemasClassHelloworld.SessionHeader_element(); strUserName = 'arvind.rao1@wipro.com.dev'; strPassword = 'hijacker56UF0IfKl12C9S1Jj9KY5uPMp'; blbHeaderValue = Blob.valueOf(strUserName + ':' + strPassword); strAuthorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(blbHeaderValue); hwb.inputHttpHeaders_x = new Map<String,String>(); system.debug('header'+strAuthorizationHeader); hwb.inputHttpHeaders_x.put('Authorization', strAuthorizationHeader); hwb.inputHttpHeaders_x.put('myHeader','myValue'); hwb.SessionHeader =new soapSforceComSchemasClassHelloworld.SessionHeader_element(); String x=hwb.sayHello('hhhh'); System.debug('testing'+x); } }

 

 I am not able to understand what am I missing here.

 

Any suggestion will be of a great help.

 

Thanks

Arvind

 

SuperfellSuperfell
Your code is sending credentials in a HTTP Authentication header, which is not supported by salesforce.com web services. You need to call the login method to get a sessionId (or get a sessionId through one of the other methods) and set the session soap header to the relevant value.
Nick34536345Nick34536345
Arvin, I strongly suggest you reset your password.
nagalakshminagalakshmi

Hi,

 

I am also facing the same problem...please help me out. how to set the session id for session header.

 

Thanks