Wsdl to PHP with Basic Auth

PHP SoapClient doesn't work for my WebService. Basic Authentication problem?

I managed to get the list of the services without including login/password in the wsdl request, so yes soapclient is working with this server.

I got a 500 error when using the login and password so it seems to be an issue on server side.

Here is the code that can help you to have more details on soap response

<?php

$username='xxx';
$password='yyy';
$WSDL_URL='https://myserver.com/services/?wsdl';

$params = array(
// witout params it works at least for the wsdl
//'login' => $username,
//'password' => $password
);
try {
$soap = new SoapClient( $WSDL_URL, $params);

$RESULT = $soap->__getFunctions();
print_r($RESULT);
// uncomment that and you'll have the error
//$soap->serviceTest('bob');
}
catch (SoapFault $fault) {
echo "SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})";
}
catch (Exception $e) {
echo $e->getMessage();
echo $e->getTraceAsString();
}

PHP consume soap service using Basic auth

php-soap has a limitation/bug, which does not allow to retrieve the WSDL while using Authentication (bug report)

You can update/upgrade your PHP version. There are people reporting that this bug is solved on 5.4.8 version.

To keep php-soap you must use a local/static version of the WSDL what I DO NOT recommend.

Although it could be less performant, I suggest you to have a look at another PHP Soap Client library, like NuSOAP.

Soap Header with Authorization Basic in native PHP

man i was so stupid:

$client = new SoapClient($wsdl, array("trace" => 1, "exceptions" => 0,
"login" => $login, "password" => $password) );

For HTTP authentication, the login and password options can be used to supply credentials.



Related Topics



Leave a reply



Submit