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
ettoregiaettoregia 

INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

Hi all,

 

I'm trying to invoke a web service from SOUP UI 5.1 but I come up with the error stated in the subject.

 

What I did is create an apex class that actually does an insert into an sObejct (see the code below).

Then I generated a wsdl file from it and imported it inside my SOAP UI env.

 

Any help would be much appreciated.

 

----------------------------------------------------------------------------------------------------------------------------------------------

global class InsertInvoice{

webService static Id makeContact(String invoiceDescr) {

Invoice_Statement__c inv = new Invoice_Statement__c(Description__c='WebServiceInvoice');
// Insert the invoice using DML.
insert inv;
return inv.id;
}
}

----------------------------------------------------------------------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!--
Web Services API : InsertInvoice
-->
<definitions targetNamespace="http://soap.sforce.com/schemas/class/InsertInvoice" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.sforce.com/schemas/class/InsertInvoice">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/InsertInvoice">
<xsd:element name="DebuggingInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="debugLog" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="ID">
<xsd:restriction base="xsd:string">
<xsd:length value="18"/>
<xsd:pattern value="[a-zA-Z0-9]{18}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="LogCategory">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Db"/>
<xsd:enumeration value="Workflow"/>
<xsd:enumeration value="Validation"/>
<xsd:enumeration value="Callout"/>
<xsd:enumeration value="Apex_code"/>
<xsd:enumeration value="Apex_profiling"/>
<xsd:enumeration value="Visualforce"/>
<xsd:enumeration value="System"/>
<xsd:enumeration value="All"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="LogCategoryLevel">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Internal"/>
<xsd:enumeration value="Finest"/>
<xsd:enumeration value="Finer"/>
<xsd:enumeration value="Fine"/>
<xsd:enumeration value="Debug"/>
<xsd:enumeration value="Info"/>
<xsd:enumeration value="Warn"/>
<xsd:enumeration value="Error"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="LogInfo">
<xsd:sequence>
<xsd:element name="category" type="tns:LogCategory"/>
<xsd:element name="level" type="tns:LogCategoryLevel"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="LogType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="None"/>
<xsd:enumeration value="Debugonly"/>
<xsd:enumeration value="Db"/>
<xsd:enumeration value="Profiling"/>
<xsd:enumeration value="Callout"/>
<xsd:enumeration value="Detail"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:element name="DebuggingHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="categories" minOccurs="0" maxOccurs="unbounded" type="tns:LogInfo"/>
<xsd:element name="debugLevel" type="tns:LogType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="CallOptions">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="client" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SessionHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="sessionId" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AllowFieldTruncationHeader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="allowFieldTruncation" type="xsd:boolean"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="makeContact">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="invoiceDescr" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="makeContactResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="tns:ID" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<!-- Message for the header parts -->
<message name="Header">
<part name="AllowFieldTruncationHeader" element="tns:AllowFieldTruncationHeader"/>
<part name="CallOptions" element="tns:CallOptions"/>
<part name="DebuggingHeader" element="tns:DebuggingHeader"/>
<part name="DebuggingInfo" element="tns:DebuggingInfo"/>
<part name="SessionHeader" element="tns:SessionHeader"/>
</message>
<!-- Operation Messages -->
<message name="makeContactRequest">
<part element="tns:makeContact" name="parameters"/>
</message>
<message name="makeContactResponse">
<part element="tns:makeContactResponse" name="parameters"/>
</message>
<portType name="InsertInvoicePortType">
<operation name="makeContact">
<input message="tns:makeContactRequest"/>
<output message="tns:makeContactResponse"/>
</operation>
</portType>
<binding name="InsertInvoiceBinding" type="tns:InsertInvoicePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="makeContact">
<soap:operation soapAction=""/>
<input>
<soap:header use="literal" part="SessionHeader" message="tns:Header"/>
<soap:header use="literal" part="CallOptions" message="tns:Header"/>
<soap:header use="literal" part="DebuggingHeader" message="tns:Header"/>
<soap:header use="literal" part="AllowFieldTruncationHeader" message="tns:Header"/>
<soap:body use="literal" parts="parameters"/>
</input>
<output>
<soap:header use="literal" part="DebuggingInfo" message="tns:Header"/>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="InsertInvoiceService">
<documentation></documentation>
<port binding="tns:InsertInvoiceBinding" name="InsertInvoice">
<soap:address location="https://na15-api.salesforce.com/services/Soap/class/InsertInvoice"/>
</port>
</service>
</definitions>

 

----------------------------------------------------------------------------------------------------------------------------------------------

Best Answer chosen by Admin (Salesforce Developers) 
ettoregiaettoregia

Hi Sean,

 

I sorted that problem out.

 

What was missing was the sessionID that I retrieved by invoking the login() operation from the partner.wsdl file.

 

Thanks for your interest.

 

Regards,

Ettore.

All Answers

Sean TanSean Tan

Can you post the SOAP message that SOAP UI sent to Salesforce when you received the illegal session error?

ettoregiaettoregia

Hi Sean,

 

I sorted that problem out.

 

What was missing was the sessionID that I retrieved by invoking the login() operation from the partner.wsdl file.

 

Thanks for your interest.

 

Regards,

Ettore.

This was selected as the best answer
Amritesh SinghAmritesh Singh

Hi ettoregia,

 

i am having same problem. Same apex class like yours working fine when i call this from my .net program using partner wsdl.

After deployed to production,my .net program showing this type of error

SESSION_ID missing ', exceptionMessage:'Invalid Session ID found in SessionHeader: Illegal Session key...


i am using production partner wsdl in .Net prgram to call apex webservice class in production.