cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

How call OneFabric Connect WebServices function from a php script?

How call OneFabric Connect WebServices function from a php script?

Antonio_Opromol
Contributor II
HI, I'm trying to made a php script (I'm not a php programmer), that execute a web services that in my example is:
https://root:password@192.168.30.34:8443/axis/services/NACWebService/addIPToEndSystemGroup?endSystem...

If I execute this web services from a web browser, it works correctly.
Then I want to execute the same command with a php script.
I've follow the examples that are in the OneFabric Connect WebServices pdf document, and my php code is the following:

$login = 'root';
$password = 'password';

try {
$client = new SoapClient(
'https://' . urlencode($login) . ':' . urlencode($password) . '@192.168.30.34:8443/axis/services/NACWebService?wsdl',
array(
'login' => $login,
'password' => $password,
'authentication' => SOAP_AUTHENTICATION_DIGEST
)
);

$response = $client->addIPToEndSystemGroup(array("endSystemGroup" => "Distributed_IPS","ipAddress" => "192.168.10.78","description" => "ck infected","reauthenticate" => true,"removeFromOtherGroups" => true));
print_r($response);

} catch (Exception $e) {
printf("Error:sendSms: %s\n",$e->__toString());
print($client->__getLastResponse());
return false;
}

?>

The problem is that this script end with an error that is the following:
root@extrememanagement.demo.com:~/scripts$ php test3.php
Error:sendSms: SoapFault exception: [Client] looks like we got no XML document in /root/scripts/test3.php:16
Stack trace:
#0 /root/scripts/test3.php(16): SoapClient->__call('addIPToEndSyste...', Array)
#1 /root/scripts/test3.php(16): SoapClient->addIPToEndSystemGroup(Array)
#2 {main}
root@extrememanagement.demo.com:~/scripts$

I've made a search on google for this error, but seams that must be correct changing same setting on the server side....

Is there someone that know how to execute this web services from the php script?

Thanks

5 REPLIES 5

Antonio_Opromol
Contributor II
Hi Kurt,

I've found the examples in the document "OneFabric Connect WebServices" that I've downloaded from the Extreme Networks site (if you want to have a look, you can download it from https://extrcdn.extremenetworks.com/wp-content/uploads/2015/05/OneFabric_Connect_API_Reference_Guide... )
Do you know if there is a more recent documentation?

Kurt_Semba
Extreme Employee
Hi Antonio,

perfect. Forget SOAP ļ˜‰ go ahead and use this working option, we've been using it for years and it is also supported by engineering.

Where did you find the reference to using SOAP for this?

Antonio_Opromol
Contributor II
Hi Kurt,
thanks for your answer.
With the simple HTTP GET request as you suggest, it works.
But I'm trying to use the method suggested from the Extreme Networks documentation and in this documentation they use the SOAP request.
Regards,
Antonio

Kurt_Semba
Extreme Employee
I don't have a php environment to test this but I would use a simple HTTP GET request instead of a SOAP request. Could you please try something like this (like I said, untested):

$username = "some-username";
$password = "some-password";
$remote_url = 'https://192.168.30.34:8443/axis/services/NACEndSystemWebService/addIPToEndSystemGroup?endSystemGroup...;

$opts = array(
'http'=>array(
'method'=>"GET",
'header' => "Authorization: Basic " . base64_encode("$username:$password")
)
);

$context = stream_context_create($opts);

// Open the file using the HTTP headers set above
$file = file_get_contents($remote_url, false, $context);

print($file);

?>

Code was taken from and adjusted in regards to the NetSight URL:
https://stackoverflow.com/questions/7732634/making-a-http-get-request-with-http-basic-authentication
GTM-P2G8KFN