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

SoapException Handling in Apex
Hello,
I am having a problem calling an external web service. The call is perfect when the return type is identical to WSDL generated Apex class, the trouble starts if the Web service throws a SoapException for a data or business rule value. The exception is caught however am not sure how to process the exception. It seems the return message is truncated in the transition between Soap message to Apex object.
Here is the response for the for the SoapException that is returned from the Web service:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Fault occurred
at MasterDataWS.GetSertAccountContactMatch(AccountRequest inAccountRequest, ContactRequest inContactRequest)</faultstring>
<detail>
<fault>
<code>10003</code>
<description>Cannot update an existing records without data passed for Last Name. This is a required field for modifying an object of type: ContactRequest.</description>
</fault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
When the exception is processed with following codes:
System.debug('====== Exception for GetSertAccountContactMatch '+ex) the response debug statement prints this:
====== Exception for GetSertAccountContactMatch System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: System.Web.Services.Protocols.SoapException: Fault occurred
at MasterDataWS.GetSertAccountContactMatch(AccountRequest inAccountRequest, ContactRequest inContactRequest) faultcode=soap:Client faultactor=
As you could see detail code and description is not present in the debug print out.
Any response from you this regard is greatly appreciated.
Regards.
I am having a problem calling an external web service. The call is perfect when the return type is identical to WSDL generated Apex class, the trouble starts if the Web service throws a SoapException for a data or business rule value. The exception is caught however am not sure how to process the exception. It seems the return message is truncated in the transition between Soap message to Apex object.
Here is the response for the for the SoapException that is returned from the Web service:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>System.Web.Services.Protocols.SoapException: Fault occurred
at MasterDataWS.GetSertAccountContactMatch(AccountRequest inAccountRequest, ContactRequest inContactRequest)</faultstring>
<detail>
<fault>
<code>10003</code>
<description>Cannot update an existing records without data passed for Last Name. This is a required field for modifying an object of type: ContactRequest.</description>
</fault>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
When the exception is processed with following codes:
System.debug('====== Exception for GetSertAccountContactMatch '+ex) the response debug statement prints this:
====== Exception for GetSertAccountContactMatch System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: System.Web.Services.Protocols.SoapException: Fault occurred
at MasterDataWS.GetSertAccountContactMatch(AccountRequest inAccountRequest, ContactRequest inContactRequest) faultcode=soap:Client faultactor=
As you could see detail code and description is not present in the debug print out.
Any response from you this regard is greatly appreciated.
Regards.
Thank you for your response. I was just wondering is it on the road map?
Best Regards.
It would be nice if the apex developers guide would at least mention these kinds of (important) missing features.
regards