Answer the question
In order to leave comments, you need to log in
Why can http authentication work incorrectly on the server for the soap service?
Good afternoon,
I completed the construction of the wsdl structure, everything is being worked out without authorization, I want to stick the simplest http authorization:
class SoapWebServiceAction extends CWebServiceAction
{
public function run()
{
header('Content-Type: text/xml; charset=utf-8');
$username = '123';
$passwd = '123';
header('X-HEADER : ' . $_SERVER['PHP_AUTH_USER'] . ':' .$_SERVER['PHP_AUTH_PW']);
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized: ' . $_SERVER['PHP_AUTH_USER'] . ':' .$_SERVER['PHP_AUTH_PW']);
echo "Вы должны ввести корректный логин и пароль для получения доступа к ресурсу";
exit;
} else {
if ($username == $_SERVER['PHP_AUTH_USER'] && $passwd == $_SERVER['PHP_AUTH_PW']) {
parent::run();
}
else {
throw new Exception($_SERVER['PHP_AUTH_USER'] . ':' .$_SERVER['PHP_AUTH_PW']);
}
}
}
...
}
Answer the question
In order to leave comments, you need to log in
Instead of
Write
And see the result)
And by the way, be careful with such password checks "=="
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question