$client = new SoapClient("http://www.example.com/webservice?wsdl"); $response = $client->getData($param1, $param2);
try { $client = new SoapClient("http://www.example.com/webservice?wsdl"); $response = $client->getData($param1, $param2); } catch (SoapFault $exception) { echo $exception->getMessage(); }In this example, we use a try-catch block to catch any SoapFault exceptions that may be thrown during the SoapClient request. If an exception is thrown, we output the error message using the getMessage() method. Package Library: PHP SoapClient is part of the PHP core, so it does not require any additional package libraries. However, some web services may require additional libraries or extensions to be installed in order to work properly.