1
I am having a problem with authentication when I try to consume a web service Soap. When entering the url in the browser, a dailog is shown asking for user and password. However, I need to do this authentication without this dialog being presented, that is, all the authentication in the back end. I tried to pass the login and password through Soapheader but without success. Follows the script:
!IMPORTANT: O tipo de autenticação é (Basic auth)
$credenciais = self::fncGeraAuth();
//array que contem user e senha para autenticação
//Array ( [UserName] => xxxxx [Password] => xxxxx)
$_rCliente2 = new SoapClient($wsdl, array("encoding" => "ISO-8859-1"));
$Header = new SoapHeader($wsdl,'Authorization', $credenciais, false);
$_rCliente2->__setSoapHeaders($Header);
$result = $_rCliente2->fncRecuperaPapel($Instituição);
//tentado acessar uma função do webservice passando um parametro
var_dump($result);
exit();
Erro:
SoapFault: SOAP-ERROR: Parsing WSDL: Couldn't load from '
...........?wsdl' : failed to load external entity ".........wsdl"
I’m still having the same error...the 'login' and 'password' item is standard for Basic Auth or you can set this to another name?
– Rafael Uemura
You can pass any key and value, in case I wait on the server the default authentication. Mount using: $_SERVER['PHP_AUTH_USER']; and $_SERVER['PHP_AUTH_PW']; The fields you will pass, depend on the server you are authenticating.
– Adriano Maciel
see how I rode $_rCliente2 = new Soapclient($_uWS, array ("encoding" => "UTF-8", "cache_wsdl"=>WSDL_CACHE_NONE, "Username" => $credentials[Username], "Password" => $credentials[Username])); in my case the web service was written in java although I believe this does not interfere.
– Rafael Uemura
Thank you Adriano...your answer worked for my problem! happens that for Basic Auth you must use "login" for the username and "password" for the password, following this pattern the authentication will successfully follow ! Thank you and success for you !!
– Rafael Uemura