cancel
Showing results for 
Search instead for 
Did you mean: 

HowTo connect WebServices via SOAP/PHP5.6.x

HowTo connect WebServices via SOAP/PHP5.6.x

Michael_Althoff
New Contributor
Hi community,
I tried to connect the WebServices via SOAP/PHP in version 5.6.18.
The short script should request all END-System MAC addresses from the NAC Appliance.
Via https://...... it works fine with the right output.
But my php script didn't work well because the wsdl file isn't accessible.
I use the Extreme pdf document "OFC-Web-Services.pdf" to try some examples.

ini_set("soap.wsdl_cache_enabled", "0"); //disable wsdl cache
$wsdl = "https://xxx.xxx.xxx.xxx:8443/axis/services/NACWebService?wsdl";
$client = new SoapClient($wsdl, array(
'trace' => 1,
'login' => "root",
'password' => "password",
'cache_wsdl' => WSDL_CACHE_NONE,
'soap_version' => SOAP_1_2
));
$response = $client->getAllEndSystemMacs();
print_r($response);
?>

The cli output looks like:
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://192.168.10.xx:8443/axis/services/NACWebService?wsdl' : failed to load external entity "https://xxx.xxx.xxx.xxx:8443/axis/services/NACWebService?wsdl";
in C:\xampp\htdocs\soap\phptest.php on line 10
PHP Fatal error: Uncaught SoapFault exception: [wsdl] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://xxx.xxx.xxx.xxx:8443/axis/services/NACWebService?wsdl
' : failed to load external entity "https://xxx.xxx.xxx.xxx:8443/axis/services/NACWebService?wsdl";
in C:\xampp\htdocs\soap\phptest.php:10
Stack trace:
#0 C:\xampp\htdocs\soap\phptest.php(10): SoapClient->SoapClient('https://xxx.xxx...', Array)
#1 {main}
thrown in C:\xampp\htdocs\soap\phptest.php on line 10
I'm not so familiar with the php versions but i guess that there was some changes from the php version in the document and the actual version 5.6.18.
I would be grateful for help

regards

Mike
6 REPLIES 6

Matthew_Hum1
Extreme Employee
According to this: http://php.net/context.ssl
you need to include a few other options. try this:
code:
$context = stream_context_create(array(     'ssl' => array(         'verify_peer' => false,         'verify_peer_name' => false,         'allow_self_signed' => true     ) ));

Matthew_Hum1
Extreme Employee
I'm sorry, I usually don't use PHP and do my calls via PERL. I talked to a friend and he said in PHP he uses the curl calls as external calls and parses the XML by himself. There are multiple ways to skin a cat, but if you are insistent on using the soapclient, I would try to look up the documentation of soapclient and see what is required for that.

The best way to troubleshoot this is to do a tcpdump and check the server response, whether or not the actual GET was sent or what HTTP status code was returned.

Michael_Althoff
New Contributor
Hi again,
I'm sorry but it doesn't work.
I'm still run into the error "Parsing WSDL: Couldn't load from 'http .........failed to load external entity".

$wsdl = "https://xxx.xxx.xxx.xxx:8443/axis/services/NACWebService?wsdl";
$contextOptions = array(
'ssl' => array(
'allow_self_signed' => true,
));
$sslContext = stream_context_create($contextOptions);
$soap = new SoapClient($wsdl, array(
'stream_context' => $sslContext,
'login' => "root",
'password' => "password"));
$response = $soap->getNACVersion();
print_r($response);

When I use a local version from the "wsdl" file, I get the error only when the function is called
$response = $soap->getNACVersion();
I suspect that the credentials are submitted incorrectly or at the wrong place.
Could it really be so difficult to get running this simple code ?
I'm really frustrated.
Regards
Mike

Matthew_Hum1
Extreme Employee
Ok, Those curl commands were to validate that it is a certificate error that you are encountering. your PHP is trying to validate the Netsight cert used in the HTTPS operation and is failing so it's not even trying to retrieve the call. You need to enable self signed certificates with PHP in order for the soapclient to ignore the self signed certificate and continue retrieving the wsdl. try using: $contextOptions = array( 'ssl' => array( 'allow_self_signed' => true, ) ); as shown here: http://stackoverflow.com/questions/12373328/how-do-i-get-the-php-soap-client-to-communicate-with-a-service-running-over-ssl
GTM-P2G8KFN