function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
srinath vallabsrinath vallab 

SOAP integration using basic authorization

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);

 
NagendraNagendra (Salesforce Developers) 
Hi Srinath,

Sincerely regret the inconvenience for the delayed reply.

It's really strange that you are getting the above error without using the certificate in the callout,mostly this error would result only in case of improper installation of the certificates.

For callouts, Apex only supports the document literal wrapped WSDL style along with primitive and built-in data types. We recommend that you validate the WSDL document and ensure that it contains supported schema types. If a type is not supported by Apex  callout to a Web service operation may result in an error returned in the callout response such as “Unable to parse callout response. Apex type not found for element item”.

Still if the problem persists  please raise a separate case with salesforce support team to get it investigated further if required.

You can reach them at http://support@salesforce.com

For more information please refer to the below links
https://help.salesforce.com/apex/HTViewSolution?id=000123530&language=en_US https://help.salesforce.com/HTViewSolution?id=000001000&language=en_US

Please mark this as solved if it helps.

Best Regards,
Nagendra.P
srinath vallabsrinath vallab
Nagendra,

Callout is taking only string, number and date type of data.

Also, I tried to execute the callout using SOAP API and it is giving success response.
I even tried to convert the SOAP call to REST and executed it using POST MAN. This is also giving me success response.
However, when I tried to execute the same REST request using developer console, it is giving "invalid certification path" error message.

Is there anything I am missing while executing via Apex or any configuration issue?
Vinicius Damasceno 1Vinicius Damasceno 1
Heey, its resolved? I have the same problem