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
Simple HTML Dom File_Get_HTML Not Working - Is There Any Workaround
Fatal Error: Call to Undefined Function Imap_Open() in PHP
Cannot Use String Offset as an Array in PHP
How to Allow Duplicate Keys in PHP Array
Apache Mod Rewrite for Laravel
Notice: Undefined Offset: 0 In
How to Embed Images in a Single HTML/PHP File
Update Query with Pdo and MySQL
PHP Multipart Form Data Put Request
Counting Occurrence of Specific Value in an Array with PHP
Converting HTML to PDF (Not PDF to HTML) Using PHP
How to Encrypt PHP Source or Compile It So Others Can't See It? and How
How to Re-Format Datetime String in PHP
How to Prevent Multiple Logins in PHP Website
Load Data Local Infile Forbidden In... PHP
How to Send 500 Internal Server Error Error from a PHP Script