How call OneFabric Connect WebServices function from a php script?

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
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:
<?php

$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
Photo of Antonio Opromolla

Antonio Opromolla

  • 2,176 Points 2k badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of Antonio Opromolla

Antonio Opromolla

  • 2,176 Points 2k badge 2x thumb
Hi, below the output of the php script if I enable the trace option in the SoapClient:
SoapFault exception: [Client] looks like we got no XML document in /root/scripts/Distributed_IPS.php:37
Stack trace:
#0 /root/scripts/Distributed_IPS.php(37): SoapClient->__call('addIPToEndSyste...', Array)
#1 /root/scripts/Distributed_IPS.php(37): SoapClient->addIPToEndSystemGroup(Array)
#2 {main}<code>POST /services/NACWebService HTTP/1.1<br />
Host: 192.168.30.34:8443<br />
Connection: Keep-Alive<br />
User-Agent: PHP-SOAP/5.5.9-1ubuntu4.21<br />
Content-Type: text/xml; charset=utf-8<br />
SOAPAction: "urn:addIPToEndSystemGroup"<br />
Content-Length: 534<br />
<br />
</code><code><span style="color: #000000">
&lt;?xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"?&gt;<br />&lt;SOAP-ENV:Envelope&nbsp;xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&nbsp;xmlns:ns1="http://ws.web.server.tam.ne... /></span>
</code><br/>
<code>HTTP/1.1 200 OK<br />
Expires: 0<br />
Expires: 0<br />
Cache-Control: no-cache, no-store, must-revalidate<br />
Cache-Control: no-cache, no-store, must-revalidate<br />
X-Powered-By: JSP/2.3<br />
Set-Cookie: JSESSIONID=i8_RbyDv3bVVInElOP9AGNfyU3ygMHXVgIWB208A.extrememanagement; path=/<br />
Server: ExtremeManagementCenter<br />
Pragma: no-cache<br />
Pragma: no-cache<br />
Date: Thu, 20 Jul 2017 13:10:28 GMT<br />
Connection: keep-alive<br />
Server-Version: 8.0.0<br />
Content-Type: text/html;charset=ISO-8859-1<br />
Content-Length: 11663<br />
</code><br/>
<code><span style="color: #000000">
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;aboutWindow&nbsp;=&nbsp;window.open&nbsp;(&nbsp;url,&nbsp;"About",&nbsp;"top="&nbsp;+&nbsp;cornerY&nbsp;+&nbsp;",left="&nbsp;+&nbsp;cornerX&nbsp;+&nbs<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;newWindow&nbsp;=&nbsp;window.open&nbsp;(&nbsp;url,&nbsp;title,&nbsp;"top="&nbsp;+&nbsp;cornerY&nbsp;+&nbsp;",left="&nbsp;+&nbsp;cornerX&nbsp;+&nbsp;",<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-image:&nbsp;-webkit-gradient(linear,&nbsp;left&nbsp;bottom,&nbsp;left&nbsp;top,&nbsp;color-stop(0,&nbsp;#3F3F3F),&nbsp;color<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-image:&nbsp;-moz-linear-gradient(center&nbsp;bottom,&nbsp;#3F3F3F&nbsp;0%,&nbsp;#383838&nbsp;50%,&nbsp;#434343&nbsp;51%,&nbs<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filter:&nbsp;progid:DXImageTransform.Microsoft.gradient(&nbsp;startColorstr='#3f3f3f',&nbsp;endColorstr='#555555',GradientType=0&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;We&nbsp;use&nbsp;the&nbsp;inset&nbsp;of&nbsp;the&nbsp;box&nbsp;shadow&nbsp;to&nbsp;create&nbsp;a&nbsp;subtle&nbsp;inner&nbsp;gl<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;a&nbsp;href='http://www.extremenetworks.com/support/'&nbsp;target='_blank'&nbsp;title="Go&nbsp;T... />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;class="form-control&nbsp;ng-pristine&nbsp;ng-valid"&nbsp;name="j_username"&nbsp;value=""&nbsp;autocorrect="o<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;class="form-control&nbsp;ng-pristine&nbsp;ng-valid"&nbsp;placeholder="Password"&nbsp;type="password"&nbsp;na<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&nbsp;id="footercontentright"&gt;Copyright&nbsp;▒&nbsp;2017&nbsp;Extreme&nbsp;Networks,&nbsp;Inc.&nbsp;All&nbsp;rights&nbsp;reserved.&lt;/div&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&<br /></span>ml&gt;lt;/body&gt;lt;/div&gt;&nbsp;&nbsp;
</code><br/>
root@extrememanagement.demo.com:~/scripts$


Seems that the server return the html page for the login where asks for username and password....
(Edited)
Photo of Kurt Semba

Kurt Semba, Employee

  • 1,366 Points 1k badge 2x thumb
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):

<?PHP
$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);<br>
?>

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
(Edited)
Photo of Antonio Opromolla

Antonio Opromolla

  • 2,176 Points 2k badge 2x thumb
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
Photo of Kurt Semba

Kurt Semba, Employee

  • 1,366 Points 1k badge 2x thumb
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?
Photo of Antonio Opromolla

Antonio Opromolla

  • 2,176 Points 2k badge 2x thumb
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?