Search code examples
phpsoap-clientsoapfault

Can PHP SoapClient throw custom SoapFaults


Is it possible to map \SoapFault to custom Exceptions like you can with objects?

I'm accessing an ESP's SOAP service through their WSDL. The WSDL defines a set of fault objects. Is it possible to create custom Exception classes so that \SoapClient will throw those instead of the generic \SoapFault?


Solution

  • Offhand, the only suggestion I can make is using set_exception_handler() to catch the \SoapFault objects and re-throw them as custom exception instances.