You need to sign in to do that
Don't have an account?
PrAnK
Web service Error (Using Salesforce webserviece in another Salesforce Org)
I am using the following Apex Web Service class.
In Remote Site Setting As end point URL
Now I am executing the following code in Developer Console.
But It shows Error
What i am doing wrong here ?
Global class SuryaDhuravSoftWebservice { webservice static String saywelcome(String Name) { return 'Hello' +Name+' welcome to salesforce Web Services'; } }I generated the WSDL and created another apex class using that WSDL, code pasted below
<!-- Web Services API : SuryaDhuravSoftWebservice --> <definitions 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/SuryaDhuravSoftWebservice" targetNamespace="http://soap.sforce.com/schemas/class/SuryaDhuravSoftWebservice"> <types> <xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/SuryaDhuravSoftWebservice"> <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="saywelcome"> <xsd:complexType> <xsd:sequence> <xsd:element name="Name" type="xsd:string" nillable="true"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="saywelcomeResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="result" type="xsd:string" 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="saywelcomeRequest"> <part element="tns:saywelcome" name="parameters"/> </message> <message name="saywelcomeResponse"> <part element="tns:saywelcomeResponse" name="parameters"/> </message> <portType name="SuryaDhuravSoftWebservicePortType"> <operation name="saywelcome"> <input message="tns:saywelcomeRequest"/> <output message="tns:saywelcomeResponse"/> </operation> </portType> <binding name="SuryaDhuravSoftWebserviceBinding" type="tns:SuryaDhuravSoftWebservicePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="saywelcome"> <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="SuryaDhuravSoftWebserviceService"> <documentation/> <port binding="tns:SuryaDhuravSoftWebserviceBinding" name="SuryaDhuravSoftWebservice"> <soap:address location="https://ap1.salesforce.com/services/Soap/class/SuryaDhuravSoftWebservice"/> </port> </service> </definitions>
In Remote Site Setting As end point URL
Now I am executing the following code in Developer Console.
soapSforceComSchemasClassSuryadhura.SuryaDhuravSoftWebservice proxyClass = new soapSforceComSchemasClassSuryadhura.SuryaDhuravSoftWebservice(); String retVal = proxyClass.saywelcome('prayank'); System.debug('------retVal----'+retVal);
But It shows 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=
What i am doing wrong here ?
But ,
I dont know what will be the line of code i need to apply to WSDL and where to apply that code