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
ksrksr 

Exception occured in WebService call WebService returned a SOAP Fault: INVALID_SESSION_ID

Hi All,

I am getting the following exception while invoking sample Web Service,  Can anyone help me?

 

WS call errorSystem.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=

 

I did the following steps:

 

Step 1: created HelloWorldWebService class

 

global class HelloWorldWebService {
   webService static string sayHello() {
        return 'Hello World!';
     }
}


Step 2: Generated WSDL file for HelloWorldWebService.cls

 

Step 3: Generated WSDL2Apex code

 

Step 4: Created the below controller "HelloWorldWSContoller.cls"

 

public class HelloWorldWSContoller{
    String uname='hai';
    public String getUsername() {
           return uname;
    }
         
    public String getHelloWorld() {
     string result = null;
        try{
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.INFO,'Inside getHelloWorld()'));           
            HelloworldServiceWSDL2Apex.HelloWorldWebService stub = new HelloworldServiceWSDL2Apex.HelloWorldWebService();
            uname = stub.sayHello();
            result = uname;
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'after webservc call.'));           
           
        }catch(Exception e){
          ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'exception occured after webservc call.'+e));                    }
        return result ;
    }
}


Step 5: Invoking the WebService using the following visualforce page

 

<apex:page controller="HelloWorldWSContoller" tabStyle="Account">
     <apex:messages styleClass="error" />
 <apex:pageBlock >
         <apex:sectionHeader title="Webservice Invocation" subtitle="{!TODAY()}"/>
        <apex:pageBlockTable value="{!HelloWorld}" var="item">
         <apex:outputText value="item"/>
           </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 

Step 5: Added remote site url in "Remote Site Settings"

 

Did I missed any steps? If so, please correct me.
Thanks in advance..!

 

Regards,
KSR