You are here

function wsclient_soap_parse_operations in Web service client 7

Convert metadata about operations provided by a SOAPClient into a wsclient compatible operations array.

Parameters

array $operations: The array containing the operation signature strings.

Return value

An operations array with parameter information.

1 call to wsclient_soap_parse_operations()
WSClientSOAPEndpoint::initializeMetadata in wsclient_soap/wsclient_soap.module
Retrieve metadata from the WSDL about available data types and operations.

File

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

Code

function wsclient_soap_parse_operations(array $operations) {
  $wsclient_operations = array();
  foreach ($operations as $operation) {
    $parts = explode(' ', $operation);
    $return_type = wsclient_soap_type_mapper($parts[0]);
    $name_parts = explode('(', $parts[1]);
    $op_name = $name_parts[0];
    $wsclient_operations[$op_name] = array(
      'label' => $op_name,
      'result' => array(
        'type' => $return_type,
        'label' => $return_type,
      ),
    );
    $parts = explode('(', $operation);

    // Cut off trailing ')'.
    $param_string = substr($parts[1], 0, -1);
    if ($param_string) {
      $parameters = explode(',', $param_string);
      foreach ($parameters as $parameter) {
        $parameter = trim($parameter);
        $parts = explode(' ', $parameter);
        $param_type = $parts[0];

        // Remove leading '$' from parameter name.
        $param_name = substr($parts[1], 1);
        $wsclient_operations[$op_name]['parameter'][$param_name] = array(
          'type' => wsclient_soap_type_mapper($param_type),
        );
      }
    }
  }
  return $wsclient_operations;
}