2

While making a library, that uses PHP's SoapClient, compatible with PHP 8.1 I came across this issue:

All properties of SoapClient are now private when they where public before. So things like getting the last soap fault ($soapClient->__soap_fault) is no longer possible. But most methods of SoapClient return null if there was a problem and the only way of knowing what went wrong is to get __soap_fault which is no longer accessible.

How should I be working with method __doRequest without having access to the properties of SoapClient?

Marc S.
  • 23
  • 6

1 Answers1

1

Looking at old SoapClient documentation, it seems that it was always an error to access the properties directly - for php7.2 e.g. __soap_fault wasn't documented at all, according to the wayback machine (see https://web.archive.org/web/20171211100753/http://us3.php.net/manual/en/class.soapclient.php)

The documentation states the following:

On error, a call to a SOAP function can cause PHP to throw exceptions or return a SoapFault object if exceptions are disabled. To check if the function call failed to catch the SoapFault exceptions, check the result with is_soap_fault().

I'd say, make sure you have exceptions enabled (by passing $options['exceptions'] => true to the SoapClient constructor) and handle those in a try/catch accordingly. If that doesn't help, a new question with a concrete error that isn't handled correctly may be more helpful.

Tom Regner
  • 6,856
  • 4
  • 32
  • 47