/** * This function is used to load a wsdl from a url, It handles the http authentication scenarios * if necessary. * @param wsdl_url WSDL url * @param username username for the digest authentication * @param password password for the digest authentication * @returns On success returns the obtained wsdl string. otherwise NULL */ function wsf_get_wsdl_str_from_url($wsdl_url, $user_parameters) { require_once 'dynamic_invocation/wsf_wsdl_consts.php'; $username = NULL; $password = NULL; $password_type = NULL; /** https client auth */ $cacert = NULL; $clientcert = NULL; $passphrase = NULL; $options = NULL; if (array_key_exists(WSF_HTTP_AUTH_USERNAME, $user_parameters)) { $username = $user_parameters[WSF_HTTP_AUTH_USERNAME]; } if (array_key_exists(WSF_HTTP_AUTH_PASSWORD, $user_parameters)) { $password = $user_parameters[WSF_HTTP_AUTH_PASSWORD]; } if (array_key_exists(WSF_HTTP_AUTH_TYPE, $user_parameters)) { $password_type = $user_parameters[WSF_HTTP_AUTH_TYPE]; } if (array_key_exists(WSF_WSDL_CA_CERT, $user_parameters)) { $cacert = $user_parameters[WSF_WSDL_CA_CERT]; } if (array_key_exists(WSF_WSDL_CLIENT_CERT, $user_parameters)) { $clientcert = $user_parameters[WSF_WSDL_CLIENT_CERT]; } if (array_key_exists(WSF_WSDL_PASSPHRASE, $user_parameters)) { $passphrase = $user_parameters[WSF_WSDL_PASSPHRASE]; } if (!is_null($username) && !is_null($password) && !is_null($password_type)) { if (strcmp($password_type, "Basic") == 0) { return wsf_get_wsdl_with_http_auth_basic($wsdl_url, $username, $password); } else { if (strcmp($password_type, "Digest") == 0) { return wsf_get_wsdl_with_http_auth_digest($wsdl_url, $username, $password); } } } else { $stream_ctx = NULL; if (!is_null($cacert) && !is_null($clientcert)) { $stream_ctx = stream_context_create(array("ssl" => array('cafile' => $cacert, 'local_cert' => $clientcert, 'verify_peer' => false))); } $result = file_get_contents($wsdl_url, 0, $stream_ctx); if (empty($result)) { throw new WSFault("Receiver", "Could not Load WSDL from {$wsdl_url}"); return NULL; } return $result; } return NULL; }
/** * This function is used to load a wsdl from a url, It handles the http authentication scenarios * if necessary. * @param wsdl_url WSDL url * @param username username for the digest authentication * @param password password for the digest authentication * @returns On success returns the obtained wsdl string. otherwise NULL */ function wsf_get_wsdl_str_from_url($wsdl_url, $user_parameters) { require_once 'dynamic_invocation/wsf_wsdl_consts.php'; $username = NULL; $password = NULL; $password_type = NULL; $options = NULL; if (array_key_exists(WSF_HTTP_AUTH_USERNAME, $user_parameters)) { $username = $user_parameters[WSF_HTTP_AUTH_USERNAME]; } if (array_key_exists(WSF_HTTP_AUTH_PASSWORD, $user_parameters)) { $password = $user_parameters[WSF_HTTP_AUTH_PASSWORD]; } if (array_key_exists(WSF_HTTP_AUTH_TYPE, $user_parameters)) { $password_type = $user_parameters[WSF_HTTP_AUTH_TYPE]; } if (!is_null($username) && !is_null($password) && !is_null($password_type)) { if (strcmp($password_type, "Basic") == 0) { return wsf_get_wsdl_with_http_auth_basic($wsdl_url, $username, $password); } else { if (strcmp($password_type, "Digest") == 0) { return wsf_get_wsdl_with_http_auth_digest($wsdl_url, $username, $password); } } } else { $result = file_get_contents($wsdl_url); if (empty($result)) { throw new WSFault("Receiver", "Could not Load WSDL from {$wsdl_url}"); return NULL; } return $result; } return NULL; }