You are here

function wsclient_soap_wsclient_service_form_validate in Web service client 7

Validation callback to check if the SOAP service URL points to a valid WSDL file.

1 string reference to 'wsclient_soap_wsclient_service_form_validate'
wsclient_soap_form_wsclient_service_form_alter in wsclient_soap/wsclient_soap.module
Implements hook_form_FORM_ID_alter().

File

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

Code

function wsclient_soap_wsclient_service_form_validate($form, $form_state) {
  $service = $form_state['wsclient_service'];
  if ($form_state['values']['type'] == 'soap' || $form_state['values']['type'] == 'soap 1.2') {

    // The url has to point to a valid WSDL file.
    try {

      // If initializing the SOAPClient succeeds we're good, otherwise we catch
      // the exception below and suppress any further warnings.
      // WARNING: if you have the xdebug PHP module enabled this can cause a
      // fatal error on invalid WSDL files (instead of a catchable SoapFault
      // exception).
      // xdebug_disable();
      @($endpoint = new SOAPClient($form_state['values']['url']));
    } catch (SoapFault $e) {
      form_set_error('url', t('Error parsing the WSDL file: %message', array(
        '%message' => $e
          ->getMessage(),
      )));
    }
  }
}