[SalesForce] Unknown Error for SOAP connection

I have created classes from WSDL2APEX, see my previous question for example: Test on WSDL2APEX classes.

But this is a different bunch of classes. The webservice in the example works well. I have read all the debug log, the only thing that is related to the error is:

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: An unknown error has occurred. faultcode=s:Client faultactor=

Here I would like to ask, how do I locate what error is happening? Is there a way for me to get the details of the error?

Thanks a lot.

Best Answer

This will be a SOAP Fault coming back from the web service. Often this will include additional information about what caused the problem. Unfortunately, Apex doesn't currently let you see this all this information. Instead it gives you a truncated version.

You have a few of options:

  1. Vote for the idea SOAPFault Information for Apex and then wait for it to be delivered
  2. If you don't have time for the currently 7 year old idea to be delivered, grab the debug log and look for the CALLOUT_RESPONSE elements. These will include a JSON and a XML version of the SOAP Response. Here you can read the full SOAP FAULT.
  3. Or, similar to 2), capture the CALLOUT_REQUEST from the log and then replay it with a tool like SOAPUI to get the response.
  4. You could also make raw HTTP callouts from Apex and process the response XML yourself.