You are here

public function WSClientSOAPEndpoint::call in Web service client 7

Calls the SOAP service.

Parameters

string $operation: The name of the operation to execute.

array $arguments: Arguments to pass to the service with this operation.

Overrides WSClientEndpoint::call

File

wsclient_soap/wsclient_soap.module, line 114
Web service client SOAP support.

Class

WSClientSOAPEndpoint
A remote endpoint type for invoking SOAP services.

Code

public function call($operation, $arguments) {
  $client = $this
    ->client();

  // Soap endpoints MAY also have 'headers' set on a per-operation basis.
  $operation_settings = $this->service->operations[$operation];
  if (!empty($operation_settings['header'])) {
    $headers = array();
    foreach ($operation_settings['header'] as $header_settings) {
      if (!empty($header_settings['actor'])) {
        $headers[] = new SoapHeader($header_settings['namespace'], $header_settings['name'], $header_settings['data'], $header_settings['mustunderstand'], $header_settings['actor']);
      }
      else {
        $headers[] = new SoapHeader($header_settings['namespace'], $header_settings['name'], $header_settings['data'], $header_settings['mustunderstand']);
      }
    }
    $client
      ->__setSoapHeaders($headers);
  }
  try {
    $response = $client
      ->__soapCall($operation, $arguments);
    return $response;
  } catch (SoapFault $e) {
    throw new WSClientException('Error invoking the SOAP service %name, operation %operation: %error', array(
      '%name' => $this->service->label,
      '%operation' => $operation,
      '%error' => $e
        ->getMessage(),
    ));
  }
}