• bow bharath 1
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

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