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
skarolinskarolin 

Callout Web Service - SOAP Fault

Currently, I am working on a POV for one of my customer.

I have a webservice hosted by a third party provider and I try to invoke this web service. So I have loaded the WSDL into Force.com (including SOAP Headers and SOAP Faults) and the APEX calsses has been created. This is working fine as long as I do not recieved a SOAP fault.

 

When the Web Service is returning a SOAP Fault, a callout exception is generated. I try to find a way to get that SOAP fault in the associated object genereted automatically but I cannot find how.

 

Is there a way to get the SOAP Fault into the SOAP Fault object generated when importing the WSDL? If not is there at least a way to retrieve to full SOAP message that was recieved?

 

Thanks

Karolinski Stéphane

SatgurSatgur

Hi,

 

You can always wrap the Web Service call out code inside a TRY/ CATCH block.

 

Apex provides CalloutException class which captures any issue with a Web service operation, such as failing to make a callout to an external system or getting an error from web service call.

 

All exception classes support built-in methods for returning the error message and exception type, so inside your catch block, you can retrieve the exact error message which will provide you with SOAP Fault code and error.

 

Did this answer your question?

 

If not, please try above suggested approach and share the outcome. We can move further accordingly.

 

Thanks

qcmikeqcmike

You mentioned you ported the WSDL (including SOAP headers and Faults).  I have been struggling to figure out where I can load SOAP headers for an Authenticated callout. How is this done?

 

sarangganisaranggani
Hi,

I having an issue passing a URL value into the header.

I have added this code:

CustomerFieldscheduling.CFSPartnerSlotsServiceImplPort cfsPort = new CustomerFieldscheduling.CFSPartnerSlotsServiceImplPort();
        
        Blob headerValue = Blob.valueOf('LOGIN' + ':' + 'LOGINPWD');
        String authorizationHeader = 'Basic ' +EncodingUtil.base64Encode(headerValue);
            String sURL = 'https:/testURL';
            System.debug('***authorizationHeader***'+authorizationHeader);
            cfsPort.inputHttpHeaders_x = new Map<String,String>();
            cfsPort.inputHttpHeaders_x.put('URL',sURL);        
            cfsPort.inputHttpHeaders_x.put('Authorization',authorizationHeader);


When i tried to invoked the webservice, able to connect to the operation that i need to call but getting the error of the URL not being part of the request that i sent

<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/>
</env:Header><env:Body>....</env:Body>

the web service is expecting a request in this format

<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>
<URL>https:/testURL</URL>
</env:Header><env:Body>

Can you please share idea on how i could attain the said format.