Overview/SOAP Interface
From Halon Security
H/OS 2.0 is controlled using SOAP (Simple Object Access Protocol) which is an XML-based RPC-over-HTTP protocol. The Web Administration included is in fact a Ajax (Web 2.0) application connecting to the backend (control process) using SOAP.
Thus, it is possible to build your own administrational interfaces and systems using the WSDL (Web Service Definition Language) file included on the appliance (http://address/halon.wsdl).
Contents |
PHP Examples
Below follows examples on how to connect to the interface using PHP.
SOAP Example
<?php
try {
/*
* Configure SoapClient to connect to Halon SPG
*/
$client = new SoapClient('<path to halon.wsdl>',array(
'location' => 'http://<host of halon>/remote/',
'uri' => 'urn:halon',
'login' => '<my username>',
'password' => '<my password>',
'connection_timeout' => 30,
'trace' => true
));
/*
* Fetch General Statitics
*/
$curtime = $client->__soapCall('System-GetKey',
array('parameters'=>
array('key'=>'system_time')
)
);
$uptime = $client->__soapCall('System-GetKey',
array('parameters'=>
array('key'=>'system_uptime')
)
);
$mail_i = $client->__soapCall('System-GetKey',
array('parameters'=>
array('key'=>'system_mail_total_in')
)
);
$mail_o = $client->__soapCall('System-GetKey',
array('parameters'=>
array('key'=>'system_mail_total_out')
)
);
$queue_i = $client->__soapCall('System-GetKey',
array('parameters'=>
array('key'=>'system_mail_queue_in')
)
);
$queue_o = $client->__soapCall('System-GetKey',
array('parameters'=>
array('key'=>'system_mail_queue_out')
)
);
echo "<b>General Information</b><br />";
echo "Current Time: ".$curtime->result->item."<br />";
echo "System Uptime: ".$uptime->result->item."<br />";
echo "<br /><b>Mail Statistics</b><br />";
echo "Mail Incoming Total: ".$mail_i->result->item."<br />";
echo "Mail Outgoing Total: ".$mail_o->result->item."<br />";
echo "Mail in Incoming Queue: ".$queue_i->result->item."<br />";
echo "Mail in Outgoing Queue: ".$queue_o->result->item."<br />";
} catch(SoapFault $f) {
var_dump($f);
}
?>
Mail Gateway Interface
Below follows examples of administrative tasks which may be useful to carry out using the SOAP interface.
Add a domain
This script requires a $client (object) see above.
$client->__soapCall('Mail-Domain-Add',
array('parameters'=>
array(
'active'=>'yes',
'name'=>'sample domain',
'domain'=>'example.org',
'incoming'=>'mailserver:1',
'outgoing'=>'mailtransport:1',
'flow'=>'mailflow:1',
'administrator'=>'admin@example.org',
'reports'=>'MTWHF 08:00',
'tpl'=>''
)
));
Delete a domain
This script requires a $client (object) see above.
$client->__soapCall('Mail-Domain-Del',
array('parameters'=>
array(
'id'=>'17'
)
));
VB.NET Example
Prepare the halon.wsdl file for VB.NET implementation.
1. Download the halon.wsdl file from http://address/halon.wsdl
2. Open the halon.wsdl file in eg. WordPad, search for "halonHeader" and remove that <message></message> key.
Create a new project in VB.NET, right click on your project in the Solution Explorer and add a new Service Reference, browse to your halon.wsdl file. Declare the HalonClient.
Dim HalonClient As New ServiceReference1.halonPortTypeClient()
HalonClient.Endpoint.Address = New System.ServiceModel.EndpointAddress("http://address/remote/?USERNAME=admin&PASSWORD=admin")
Mail Gateway Interface
Add a domain
Try
HalonClient.MailDomainAdd("yes", "my domain", "example.org", "mailserver:1", "mailtransport:1", "mailflow:1", "", "", "")
Catch ex As Exception
MsgBox("Failed to add domain")
End Try
List all domains
Dim keylist() As ServiceReference1.configKey
keylist = HalonClient.ConfigGetKeysLike("mail_domain__")
For i = 0 To keylist.Length() - 1
MsgBox(keylist.ToArray(i).params.ToArray(2).ToString())
Next
