You need to sign in to do that
Don't have an account?

Problem in integrate sfdc to sap/pi
Hi ,
My scenario is , if i create a employee details record in in salesforce , It will be Display in SAP/PI.
Employee objects
Fields - Name,Ename__c & Salary__c
Steps:
1) generate Apex class from sap/pi WSDL
2) create a new apex class (future methods ) and set enerated class end point.
3) write a trigger , to call future methods apex class
Generated Apex class from SAP PI system
public class intrigoSoapSforceCom456 {
public class HTTPS_Port {
public String endpoint_x = 'http://ca-in02:520/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SFDCTEST&receiverParty=&receiverService=&interface=SI_SFDC_OUT&interfaceNamespace=urn:intrigo.soap.sforce.com';
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;
private String[] ns_map_type_info = new String[]{'urn:intrigo.soap.sforce.com', 'intrigoSoapSforceCom456'};
public intrigoSoapSforceCom456.Response_element[] SI_SFDC_OUT(intrigoSoapSforceCom456.Employee_element[] Employee) {
intrigoSoapSforceCom456.SfdcTest_Request request_x = new intrigoSoapSforceCom456.SfdcTest_Request();
intrigoSoapSforceCom456.SFDCResponse response_x;
request_x.Employee = Employee;
Map<String, intrigoSoapSforceCom456.SFDCResponse> response_map_x = new Map<String, intrigoSoapSforceCom456.SFDCResponse>();
response_map_x.put('response_x', response_x);
WebServiceCallout.invoke(
this,
request_x,
response_map_x,
new String[]{endpoint_x,
'http://sap.com/xi/WebService/soap1.1',
'urn:intrigo.soap.sforce.com',
'MT_SFDC_Request',
'urn:intrigo.soap.sforce.com',
'MT_SFDC_Response',
'intrigoSoapSforceCom456.SFDCResponse'}
);
response_x = response_map_x.get('response_x');
return response_x.Response;
}
}
public class Response_element {
public String sapno;
private String[] sapno_type_info = new String[]{'sapno','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
private String[] field_order_type_info = new String[]{'sapno'};
}
public class SFDCResponse {
public intrigoSoapSforceCom456.Response_element[] Response;
private String[] Response_type_info = new String[]{'Response','urn:intrigo.soap.sforce.com','Response_element','1','-1','false'};
private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
private String[] field_order_type_info = new String[]{'Response'};
}
public class Employee_element {
public String EmployeeNo;
public String Ename;
public String Salary;
private String[] EmployeeNo_type_info = new String[]{'EmployeeNo','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] Ename_type_info = new String[]{'Ename','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] Salary_type_info = new String[]{'Salary','http://www.w3.org/2001/XMLSchema','string','0','1','false'};
private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
private String[] field_order_type_info = new String[]{'EmployeeNo','Ename','Salary'};
}
public class SfdcTest_Request {
public intrigoSoapSforceCom456.Employee_element[] Employee;
private String[] Employee_type_info = new String[]{'Employee','urn:intrigo.soap.sforce.com','Employee_element','1','-1','false'};
private String[] apex_schema_type_info = new String[]{'urn:intrigo.soap.sforce.com','false','false'};
private String[] field_order_type_info = new String[]{'Employee'};
}
}
Apex class :
global class WebServiceCallout123 {
@future (callout=true)
WebService static void sendNotification(String EmployeeNo ,String Ename, String Salary) {
//Set your username and password here
String username = 'nreddy';
String password = 'sappi123';
//Construct HTTP request and response
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
//Construct Authorization and Content header
Blob headerValue = Blob.valueOf(username+':'+password);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setHeader('Content-Type','application/json');
//Set Method and Endpoint and Body
req.setMethod('POST');
req.setEndpoint('http://ca-in02:520/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_SFDCTEST&receiverParty=&receiverService=&interface=SI_SFDC_OUT&interfaceNamespace=urn:intrigo.soap.sforce.com');
req.setBody('{"EmployeeNo":"'+EmployeeNo+'","ename":"'+ename+'","Salary":"'+Salary+'"}');
System.debug('EmployeeNo -->' + EmployeeNo);
try {
//Send endpoint to JIRA
res = http.send(req);
} catch(System.CalloutException e) {
System.debug(res.toString());
}
}
public static testMethod void testMe() {
WebServiceCallout123.sendNotification('aza','aza','aza');
}
}
trigger:
trigger InsertEcc on Employee__c (after Insert) {
for(Employee__c s:Trigger.New)
{
WebServiceCallout123.sendNotification(s.Name,s.Ename__c,s.Salary__c);
System.debug('Emp data -->' + s);
}
}
The problem is it is not affected in sap /pi. Any body have a idea. what wrong i done? please help me
i believe you add the end point URL in remote site setting
did you check with sap team are they get any calls form Salesforce
Also what was the response you get in salesforce when you call the sap service
Hi,
I add endpoint url in remote setting also. I checked with SAP Team, nothing can hit in SAP. for response URL is not properly retrieved(forbidden) and Access denied. if u have any code plz share me.
The following steps I done.
a) generate WSDL in SAP/PI(soap adapter)
b) call endpoint url in http class and called the apex class in trigger
Hi SRK, I set Endpoint url in remote settings. but it is not hitting in SAP/PI.
Debug log
Hi Dragon,
I have to work on the same thing.Have u got this resolved ,can u please help?
Same code is work perfectly... set correct endpoint URL
Hi Dragon,
Thanks a lot for your reply.
On thing which confuses me about your code is that ,You have geenrated classes from wsdl fille and then you are using Rest based web services,
You are combining soap based structure as well as rest based in which you specify end point URL and then send data using HTTP etc.Which makes me believe you are actually using rest based mechanism using json mechanism not using wsdl to apex generated classes.Am I correct.?
As far as my knowledge is concerned about soap,which is not much?
When we use soap based web services,We extract wsdl to apex and then we call functions from the generarted classes.I mean we make callout's in which we specify parameters and then we get response back from the webservcies and we display that to the user.When I look at your code I do not see that you are calling any function from wsdl generated classes.?Am I missing something ?
Can u please clarify whether you have used soap or rest based web servcies?.Please help if I am missing something,Please correct or advise.
Moreover,Are u not making use of the External id's?
Thanks once again for your help.
Hi Dragon,
What kind of authetication mechanism you followed for connecting salesforce with sap.Since you have specified username and password of sap in the code.Did that allow you to establish connection with the sap.
Another question ,So basically from sap generated wsdl files in salesforce you are only using sap endpoint in saleforce.IS that correct?
Can u please help be answering these questions?
StatusCode=200 message. Hope it helps someone.
CALLOUT_RESPONSE [34]|System.HttpResponse[Status=Forbidden, StatusCode=403]