$client = new SoapClient('http://example.com/soap.wsdl'); $response = $client->someMethod(); echo $response; echo $client->__getLastResponse();
$client = new SoapClient('http://example.com/soap.wsdl'); try { $response = $client->someMethodWithFault(); } catch (SoapFault $fault) { echo $fault->getMessage(); echo $client->__getLastResponse(); }In this example, the `someMethodWithFault()` SOAP method is called on the client object, which results in a SOAP error. Since the method call is enclosed in a `try-catch` block, the fault is caught and its message is printed to the screen. Additionally, `__getLastResponse()` is called to get the underlying XML of the error message. It is difficult to determine the specific package library being used with these code examples, as the `SoapClient` class is provided by PHP itself as a part of the core language. However, depending on the SOAP server being used by the client, there may be additional packages or extensions required for communicating with it.