• Vinicius Damasceno 1
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hi all, 

Im in a trouble while connecting Salesforce to SAP(external system).

I got the wsdl and made the Apex Class.
I have generated the Self Signed Certificate, i put the certificate in Identity Provider.
I Downloaded the certificate and send the certificate as "pem" file to others persons, that said they have installed this "pem" file in the endpoint server.

But I got this error "Line: 84, Column: 1
System.CalloutException: IO Exception: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
when i try to execute the request to webService.

This is my apex Class:

//Generated by wsdl2apex

public class filtrarProdutoIntegracao {
    public class Result_element {
        public String matnr;
        public String netpr;
        public String netwr;
        public String mwsbp;
        public String aufsg;
        private String[] matnr_type_info = new String[]{'matnr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] netpr_type_info = new String[]{'netpr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] netwr_type_info = new String[]{'netwr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] mwsbp_type_info = new String[]{'mwsbp','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] aufsg_type_info = new String[]{'aufsg','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://******.com.br/SALESFORCE/ConsultaPrecoMaterial','false','false'};
        private String[] field_order_type_info = new String[]{'matnr','netpr','netwr','mwsbp','aufsg'};
    }
    public class DT_ConsPrecoMaterial_OB {
        public String vtweg;
        public String werks;
        public String kunnag;
        public String[] matnr;
        public String mgame;
        public String vkpne;
        public String skfbp;
        private String[] vtweg_type_info = new String[]{'vtweg','http://*****..com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] werks_type_info = new String[]{'werks','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] kunnag_type_info = new String[]{'kunnag','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] matnr_type_info = new String[]{'matnr','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','-1','false'};
        private String[] mgame_type_info = new String[]{'mgame','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] vkpne_type_info = new String[]{'vkpne','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] skfbp_type_info = new String[]{'skfbp','http://******.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'1','1','false'};
        private String[] apex_schema_type_info = new String[]{'http://******.com.br/SALESFORCE/ConsultaPrecoMaterial','false','false'};
        private String[] field_order_type_info = new String[]{'vtweg','werks','kunnag','matnr','mgame','vkpne','skfbp'};
    }
    public class DT_ConsPrecoMaterial_IB {
        public filtrarProdutoIntegracao.Result_element[] Result;
        private String[] Result_type_info = new String[]{'Result','http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial',null,'0','-1','false'};
        private String[] apex_schema_type_info = new String[]{'http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial','false','false'};
        private String[] field_order_type_info = new String[]{'Result'};
    }
    public class HTTPS_Port {
        public String endpoint_x = 'https://*******.com.br:44300/XISOAPAdapter/MessageServlet?senderParty=SALESFORCE&senderService=SALESFORCE&receiverParty=SALESFORCE&receiverService=SALESFORCE&interface=SI_ConsPrecoMaterial_OB&interfaceNamespace=http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial';
        public Map<String,String> inputHttpHeaders_x = new Map<String,String>();   
        public Map<String,String> outputHttpHeaders_x;
        public String clientCertName_x = 'SelfSignedCert_300522';
       // public String clientCert_x;
        //public String clientCertPasswd_x;
        public Integer timeout_x;
        private String[] ns_map_type_info = new String[]{'http://*****/SALESFORCE/ConsultaPrecoMaterial', 'filtrarProdutoIntegracao'};
        public filtrarProdutoIntegracao.Result_element[] SI_ConsPrecoMaterial_OB(String vtweg,String werks,String kunnag,List<String> matnr,String mgame,String vkpne,String skfbp) {
            filtrarProdutoIntegracao.DT_ConsPrecoMaterial_OB request_x = new filtrarProdutoIntegracao.DT_ConsPrecoMaterial_OB();
            request_x.vtweg = vtweg;
            request_x.werks = werks;
            request_x.kunnag = kunnag;
            request_x.matnr = matnr;
            request_x.mgame = mgame;
            request_x.vkpne = vkpne;
            
            request_x.skfbp = skfbp;
            filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB response_x;
            Map<String, filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB> response_map_x = new Map<String, filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB>();
            response_map_x.put('response_x', response_x);
            //inputHttpHeaders_x.put('Authorization','Basic SU5URUdfU0Y=:MW50M2dyQDIwMjI=');
            WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              'http://sap.com/xi/WebService/soap1.1',
              'http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial',
              'MT_ConsPrecoMaterial_OB',
              'http://*****.com.br/SALESFORCE/ConsultaPrecoMaterial',
              'MT_ConsPrecoMaterial_IB',
              'filtrarProdutoIntegracao.DT_ConsPrecoMaterial_IB'}
            );
            response_x = response_map_x.get('response_x');
            return response_x.Result;
        }
    }
}


I'm stuck somedays in this problems, im glad if someone help me! =)
I have an issue where in my action.setCallBack is not being run.
When user closes the tab, the component call a function onTabClosed.
onTabClosed : function(component, event, helper) {
var aCaseId = component.get("v.recordId");
console.log('yep');
var action = component.get("c.hasCustomerInteractionOpenA");
action.setParams({aCaseId : aCaseId});
action.setCallback(this, function(response) {
console.log('callBack');
var state = response.getState();
var result = response.getReturnValue();
//console.log('BKO Picklist values ' +JSON.stringify(result));
if (state === "SUCCESS") {
console.log('test1');
component.set("v.checkTab",true); }
else{
console.log('test2');
component.set("v.checkTab",true);
} });
$A.enqueueAction(action);

console.log('yep1'); },


The console.log inside callBack is not being executed. Only the console.log(yep1) and (yep2).


Here is the Apex:
@AuraEnabled public static Boolean hasCustomerInteractionOpen(String aCaseId){

try{
Case lCase = [SELECT AttendanceProtocol__c, Id, Status, AttendanceProtocol__r.LastModifiedDate, AttendanceProtocol__r.vlocity_cmt__Status__c, OwnerId FROM Case WHERE Id =: aCaseId LIMIT 1];
if((String.isNotBlank(lCase.AttendanceProtocol__c)) && (lCase.AttendanceProtocol__r.vlocity_cmt__Status__c != 'Closed') && (lCase.OwnerId == (UserInfo.getUserId()))){

List<Case> lCaseCustomer = [SELECT Id,AttendanceProtocol__c, Status, ClosedDate FROM Case WHERE AttendanceProtocol__c =: lCase.AttendanceProtocol__c ORDER BY ClosedDate DESC];

if((lCaseCustomer[0].Id == lCase.Id) && ((lCase.AttendanceProtocol__r.LastModifiedDate) < (lCaseCustomer[0].ClosedDate))){

System.debug('true'); return true; }
} System.debug('false');
return false;
}catch(Exception e){ System.debug('The following exception has occurred: ' + e.getMessage()); return false; } }


The system.debug is returning in the debugging. So, the apex is being called, returning a value.
But the action.setCallBack is not accessing this value. I'm on it has two days, someone can help me? Really appreciate it.
I have an issue where in my action.setCallBack is not being run.
When user closes the tab, the component call a function onTabClosed.
onTabClosed : function(component, event, helper) {
var aCaseId = component.get("v.recordId");
console.log('yep');
var action = component.get("c.hasCustomerInteractionOpenA");
action.setParams({aCaseId : aCaseId});
action.setCallback(this, function(response) {
console.log('callBack');
var state = response.getState();
var result = response.getReturnValue();
//console.log('BKO Picklist values ' +JSON.stringify(result));
if (state === "SUCCESS") {
console.log('test1');
component.set("v.checkTab",true); }
else{
console.log('test2');
component.set("v.checkTab",true);
} });
$A.enqueueAction(action);

console.log('yep1'); },


The console.log inside callBack is not being executed. Only the console.log(yep1) and (yep2).


Here is the Apex:
@AuraEnabled public static Boolean hasCustomerInteractionOpen(String aCaseId){

try{
Case lCase = [SELECT AttendanceProtocol__c, Id, Status, AttendanceProtocol__r.LastModifiedDate, AttendanceProtocol__r.vlocity_cmt__Status__c, OwnerId FROM Case WHERE Id =: aCaseId LIMIT 1];
if((String.isNotBlank(lCase.AttendanceProtocol__c)) && (lCase.AttendanceProtocol__r.vlocity_cmt__Status__c != 'Closed') && (lCase.OwnerId == (UserInfo.getUserId()))){

List<Case> lCaseCustomer = [SELECT Id,AttendanceProtocol__c, Status, ClosedDate FROM Case WHERE AttendanceProtocol__c =: lCase.AttendanceProtocol__c ORDER BY ClosedDate DESC];

if((lCaseCustomer[0].Id == lCase.Id) && ((lCase.AttendanceProtocol__r.LastModifiedDate) < (lCaseCustomer[0].ClosedDate))){

System.debug('true'); return true; }
} System.debug('false');
return false;
}catch(Exception e){ System.debug('The following exception has occurred: ' + e.getMessage()); return false; } }


The system.debug is returning in the debugging. So, the apex is being called, returning a value.
But the action.setCallBack is not accessing this value. I'm on it has two days, someone can help me? Really appreciate it.
We are experiencing error in connecting from Salesforce(using developer console for now) to SAP PI using SOAP API callout.
 
From developer console when we try to make a SOAP API callout, the below error is encountered, but we are not using the Certificate in the callout instead we are using basic authentication i.e., user credentials.
 
Error:
System.CalloutException: IO Exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

The below code is used in the Console to connect to SAP PI:
 
SOAPClass timesvar=new SOAPClass();
timesvar.inputHttpHeaders_x=new Map<String,String>();
 
Blob headerValue = Blob.valueOf('<Username>' + ':' + '<Password>');
String authorizationHeader = 'BASIC '+ EncodingUtil.base64Encode(headerValue);
timesvar.inputHttpHeaders_x.put('Authorization', authorizationHeader);
timesvar.inputHttpHeaders_x.put('Content-Type', 'text/xml');
 
ResponseClass response=timesvar.SOAPMethod( <arguments>);
System.debug(response);