|
Version: 1
HCnix Build: 3.00 and later
API Build: 1.00 and later
Server Manager - GetServers retrieves all servers in cluster. This web service call can be made as http://your-domain.com/HC8API/ServerManager.php?op=GetServers.
Input Parameters
HostUserName
HostPassword
OptionalParam
Role - possible values are Web Server, DNS Server, Mail Server, Database Server, Virtualization Server
ServerName - search filter, if you want to get details of a specific server
Language
Output Parameters
ServerID - a unique identification number given to each server
ServerName - name of the server
Role - role of the server i.e. Web Server or Mail Server etc.
Capacity - capacity of server according to role in cluster
Consumed - consumed part of total capacity
Sample Optional Parameters
<Parameters>
<Parameter Name = "Role">DNS Server</Parameter>
<Parameter Name = "Language">French</Parameter>
</Parameters>
Sample SOAP Request
POST /HCnixAPI/Servermanager.php HTTP/1.1 Host: your-domain.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/GetServers" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <GetServers xmlns="http://tempuri.org/"> <HostUserName>host</HostUserName> <HostPassword>host123</HostPassword> <OptionalParam>xml</OptionalParam> </GetServers> </soap:Body> </soap:Envelope>
|
Sample HTTP Request
POST /HCnixAPI/Servermanager.php/GetServers HTTP/1.1 Host: your-domain.com Content-Type: application/x-www-form-urlencoded Content-Length: length HostUserName=host&HostPassword=host&OptionalParam=xml
|
Sample PHP Code
function GetServers($strHostUserName, $strHostPassword, $OptionalParam) { $response=""; $soapPacket = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetServers xmlns=\"http://tempuri.org/\"> <HostUserName>$strHostUserName</HostUserName> <HostPassword>$strHostPassword</HostPassword> <OptionalParam>$OptionalParam</OptionalParam> </GetServers> </soap:Body> </soap:Envelope>"; //$domain_name is where HCnix APIs are installed $fp = fsockopen($domain_name, 80, $errNo, $errString, 90);
if($fp) { $header = "POST /$name/UserManager.php HTTP/1.1\r\n"; //where $name is the Virtual Directory name for HCnix APIs $header .= "HOST: $domain_name\n"; $header .= "Content-Type: text/xml;charset=\"utf-8\"\r\n"; $header .= "Content-Length: ".strlen($soapPacket)."\r\n\r\n"; fwrite($fp, $header.$soapPacket);
while (true) { $buffer = fread($fp, 1000); if( $buffer != "" ) $response .= $buffer; if(strstr($response, '</SOAP-ENV:Envelope>') || $buffer == "" ) break; $buffer = ""; } fclose($fp); $result = explode("<?xml",$response); return "<?xml".$result[1]; } }
|
Sample Response
<Response> <Method>GetServers</Method> <Status>true</Status>
<Result> <Servers xmlns=""> <RecordRow> <ServerID>1</ServerID> <ServerName>abc</ServerName> <Role>Web Server</Role> <Capacity>700</Capacity> <Consumed>4</Consumed> </RecordRow> <RecordRow> <ServerID>1</ServerID> <ServerName>abc</ServerName> <Role>DNS Server</Role> <Capacity>500</Capacity> <Consumed>6</Consumed> </RecordRow> ....... ....... ....... </Servers> </Result> </Response>
|