You need to sign in to do that
Don't have an account?
Karna_Shiva
Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor
public class soapSforceComSchemasClassAccountins {
public class SessionHeader_element {
public String x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ;
private String[] x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ_type_info = new String[]{'00D90000000y0lh!AQ0AQGIsi542TCnp.73StsP8nawV5.7uVrHfVM0SyclcA.h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
private String[] field_order_type_info = new String[]{'x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ'};
}
public class DebuggingInfo_element {
public String debugLog;
private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
private String[] field_order_type_info = new String[]{'debugLog'};
}
public class AccountInsert {
public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/AccountInsert';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
public soapSforceComSchemasClassAccountins.SessionHeader_element SessionHeader;
public soapSforceComSchemasClassAccountins.DebuggingInfo_element DebuggingInfo;
public soapSforceComSchemasClassAccountins.CallOptions_element CallOptions;
public soapSforceComSchemasClassAccountins.DebuggingHeader_element DebuggingHeader;
public soapSforceComSchemasClassAccountins.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/AccountInsert';
private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/AccountInsert';
private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/AccountInsert';
private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/AccountInsert';
private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/AccountInsert';
private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert', 'soapSforceComSchemasClassAccountins'};
public void opportunityUpdate(String Name,String AccountNumber,String Description) {
soapSforceComSchemasClassAccountins.opportunityUpdate_element request_x = new soapSforceComSchemasClassAccountins.opportunityUpdate_element();
request_x.Name = Name;
request_x.AccountNumber = AccountNumber;
request_x.Description = Description;
soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element response_x;
Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element> response_map_x = new Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://soap.sforce.com/schemas/class/AccountInsert',
'opportunityUpdate',
'http://soap.sforce.com/schemas/class/AccountInsert',
'opportunityUpdateResponse',
'soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element'}
);
response_x = response_map_x.get('response_x');
}
}
}
executing through Developer Console from other Salesforce Org:::
soapSforceComSchemasClassAccountins.AccountInsert a = new soapSforceComSchemasClassAccountins.AccountInsert();
a.opportunityUpdate('Microsoft','21232','Cognizant');
Line: 111, Column: 1
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=
public class SessionHeader_element {
public String x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ;
private String[] x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ_type_info = new String[]{'00D90000000y0lh!AQ0AQGIsi542TCnp.73StsP8nawV5.7uVrHfVM0SyclcA.h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
private String[] field_order_type_info = new String[]{'x00D90000000y0lh_AQ0AQGIsi542TCnp_73StsP8nawV5_7uVrHfVM0SyclcA_h1XKIVMRIiQAFjveUkYoo0HcVFXVHV1J6vjgM92eC2mdTmQCWQ'};
}
public class DebuggingInfo_element {
public String debugLog;
private String[] debugLog_type_info = new String[]{'debugLog','http://soap.sforce.com/schemas/class/AccountInsert',null,'1','1','false'};
private String[] apex_schema_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert','true','false'};
private String[] field_order_type_info = new String[]{'debugLog'};
}
public class AccountInsert {
public String endpoint_x = 'https://ap1.salesforce.com/services/Soap/class/AccountInsert';
public Map<String,String> inputHttpHeaders_x;
public Map<String,String> outputHttpHeaders_x;
public String clientCertName_x;
public String clientCert_x;
public String clientCertPasswd_x;
public Integer timeout_x;
public soapSforceComSchemasClassAccountins.SessionHeader_element SessionHeader;
public soapSforceComSchemasClassAccountins.DebuggingInfo_element DebuggingInfo;
public soapSforceComSchemasClassAccountins.CallOptions_element CallOptions;
public soapSforceComSchemasClassAccountins.DebuggingHeader_element DebuggingHeader;
public soapSforceComSchemasClassAccountins.AllowFieldTruncationHeader_element AllowFieldTruncationHeader;
private String SessionHeader_hns = 'SessionHeader=http://soap.sforce.com/schemas/class/AccountInsert';
private String DebuggingInfo_hns = 'DebuggingInfo=http://soap.sforce.com/schemas/class/AccountInsert';
private String CallOptions_hns = 'CallOptions=http://soap.sforce.com/schemas/class/AccountInsert';
private String DebuggingHeader_hns = 'DebuggingHeader=http://soap.sforce.com/schemas/class/AccountInsert';
private String AllowFieldTruncationHeader_hns = 'AllowFieldTruncationHeader=http://soap.sforce.com/schemas/class/AccountInsert';
private String[] ns_map_type_info = new String[]{'http://soap.sforce.com/schemas/class/AccountInsert', 'soapSforceComSchemasClassAccountins'};
public void opportunityUpdate(String Name,String AccountNumber,String Description) {
soapSforceComSchemasClassAccountins.opportunityUpdate_element request_x = new soapSforceComSchemasClassAccountins.opportunityUpdate_element();
request_x.Name = Name;
request_x.AccountNumber = AccountNumber;
request_x.Description = Description;
soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element response_x;
Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element> response_map_x = new Map<String, soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'',
'http://soap.sforce.com/schemas/class/AccountInsert',
'opportunityUpdate',
'http://soap.sforce.com/schemas/class/AccountInsert',
'opportunityUpdateResponse',
'soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element'}
);
response_x = response_map_x.get('response_x');
}
}
}
executing through Developer Console from other Salesforce Org:::
soapSforceComSchemasClassAccountins.AccountInsert a = new soapSforceComSchemasClassAccountins.AccountInsert();
a.opportunityUpdate('Microsoft','21232','Cognizant');
Line: 111, Column: 1
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=
partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap();
partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('karnashiva@cognizant.com.dev', 'Password123');
soapSforceComSchemasClassAccountins.SessionHeader_element webserviceSessionHeader = new soapSforceComSchemasClassAccountins.SessionHeader_element();
webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
soapSforceComSchemasClassAccountins.AccountInsert myWebservice = new soapSforceComSchemasClassAccountins.AccountInsert();
myWebservice.SessionHeader = webserviceSessionHeader;
myWebservice.opportunityUpdate('Sriram','1232323232323','Descriptiopn');
All Answers
1. Generated Partner wsdl from 1st org.
2. Generated Custom Apex class wsdl from 1st org.
3. Generated session id with 1st org credentials using partner wsdl and placed session id in 1st org apex class wsdl
-<xsd:element name="SessionHeader"> -<xsd:complexType> -<xsd:sequence> <xsd:element name="00D90000000y0lh!AQ0AQEnYr4zUvNkvVtixpSdjLtqnNobqSzoi2Oa9jl3U.G8ceH44tP1qWCeO80.ErWCp4_P3acIM1z9baS0LwAq8j3U89vgN" type="xsd:string"/> </xsd:sequence>
</xsd:complexType> </xsd:element>
4. imported Partner wsdl & Apex class wsdl into 2nd org
executed through Developer Console from 2nd Salesforce Org:::
soapSforceComSchemasClassAccountins.AccountInsert a = new soapSforceComSchemasClassAccountins.AccountInsert();
Passing Account Name, Number - Text Data Type, Description
a.opportunityUpdate('Microsoft','21232','Cognizant');
Plz some help me on this.
String username = 'karnashiva@cognizant.com.dev';
String password = 'XXXXXXXX';
partnerSoapSforceCom.LoginResult loginResult = sp.login(username, password);
system.debug(' loginResult ' + loginResult);
soapSforceComSchemasClassAccountins.AccountInsert apexWebSvc = new soapSforceComSchemasClassAccountins.AccountInsert();
soapSforceComSchemasClassAccountins.SessionHeader_element sessionHeader = new soapSforceComSchemasClassAccountins.SessionHeader_element();
sessionHeader.sessionId = loginResult.sessionId;
system.debug(' loginResult ' + sessionHeader.sessionId);
apexWebSvc.timeout_x = 120000;
apexWebSvc.SessionHeader = sessionHeader;
apexWebSvc.opportunityUpdate('Microsoft','21232','Cognizant');
While executing this method it is throwing error:
WebServiceCallout.invoke(
this,request_x,response_map_x,new String[]{endpoint_x,'','http://soap.sforce.com/schemas/class/AccountInsert',
'opportunityUpdate','http://soap.sforce.com/schemas/class/AccountInsert','opportunityUpdateResponse',
'soapSforceComSchemasClassAccountins.opportunityUpdateResponse_element'});
Error Msg:
Line: 111, Column: 1
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Element {http://soap.sforce.com/schemas/class/AccountInsert}SessionId invalid at this location faultcode=soapenv:Client faultactor
<?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header><SessionHeader xmlns="http://soap.sforce.com/schemas/class/AccountInsert">
<SessionId>00D90000000y0lh!AQ0AQExjhThcP_mzVa9LtKOIEHYZi2TI1JA1OT9LPLanvgFmC.USdbQPFKqatz1qhB9PWcg60LqNj96FZZg9xnaybAEHjBPw</SessionId>
</SessionHeader></env:Header><env:Body><opportunityUpdate xmlns="http://soap.sforce.com/schemas/class/AccountInsert">
<Name>Microsoft</Name>
<AccountNumber>21232</AccountNumber>
<Description>Cognizant</Description></opportunityUpdate>
</env:Body></env:Envelope>
CALLOUT_RESPONSE: Getting error in CAllOUT RESPONSE
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>Element {http://soap.sforce.com/schemas/class/AccountInsert}SessionId invalid at this location</faultstring></soapenv:Fault></soapenv:Body></soapenv:Envelope>
System.CalloutException: Web service callout failed: WebService returned a SOAP Fault:
Element {http://soap.sforce.com/schemas/class/AccountInsert}SessionId invalid at this location faultcode=soapenv:Client faultactor=
partnerSoapSforceCom.Soap myPartnerSoap = new partnerSoapSforceCom.Soap();
partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('karnashiva@cognizant.com.dev', 'Password123');
soapSforceComSchemasClassAccountins.SessionHeader_element webserviceSessionHeader = new soapSforceComSchemasClassAccountins.SessionHeader_element();
webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;
soapSforceComSchemasClassAccountins.AccountInsert myWebservice = new soapSforceComSchemasClassAccountins.AccountInsert();
myWebservice.SessionHeader = webserviceSessionHeader;
myWebservice.opportunityUpdate('Sriram','1232323232323','Descriptiopn');
Your code did work and helped much of unnecessary rework. Kudos !...Need more people like you in the Salesforce world. Thanks!!