|
This reference is also available in
PDF format.
What Is H-Sphere XML API
H-Sphere XML API, written in Java, is designed to manage H-Sphere services from remote applications
via SOAP. It uses the
Apache Axis implementation of SOAP
and runs under the Apache Tomcat engine.
Remote applications interact with CP services by means of XML-formatted requests
transferred via HTTP (direct TCP connection can also be set up).
Error messages are also processed in XML.
XML schema is based on the SOAP RPC convention.
Mechanism of Interaction
XML API provides the following mechanism of communication between remote applications and the Control Panel:
- A remote Java application calls CP methods to perform particular actions
(for example, to create an account or to return the list of domains).
For this, it invokes its SOAP client to form the corresponding XML request and to http it
to the Control Panel;
- the CP SOAP server receives this XML request,
parses the request and calls a target H-Sphere service;
- the target H-Sphere service performs actions according to the received request
(for example, creates an account or returns the list of domains),
and responds via the SOAP server to the remote application.
If the request is incorrect, the SOAP server returns a SOAP fault.
Therefore, though HTTP is used for data transfer, H-Sphere XML API services are not called from a Web browser!
Where To Get H-Sphere XML API
You can download
Axis libraries and
the latest version of
H-Sphere Axis-based Web services
from PSoft site.
Also, you can test H-Sphere XML functionality with our
sample Java classes.
How To Enable And Test H-Sphere XML API
Please read a separate document on enabling and testing H-Sphere XML API.
Services
Actions supported by XML API are grouped by services:
XML Message Structure
Each XML request/response message is wrapped into a SOAP envelope:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
</soapenv:Envelope>
Inside the SOAP envelope, message body is enclosed into the <soapenv:Body> tag:
<soapenv:Body>
. . .
</soapenv:Body>
Later in the H-Sphere XML API documentation, only the SOAP message body is considered.
Inside the SOAP body, operations are defined as follows:
<ns1:deleteDomain soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="DomainServices">
Here:
- ns1:deleteDomain is an operation;
- xmlns:ns1="DomainServices" is its service.
Then, the operation parameters are listed:
<domain xsi:type="xsd:string">domain.comt</domain>
Here:
- domain is a parameter's name;
- xsi:type="xsd:string" defines the parameter's type.
More on supported types
- xsi:nil="true" - this attribute is set to true if the parameter can take the null value.
Complex value definition:
<at href="#id0"/>
where:
- at is a parameter's name
- href="#id0" - refers to the value of the parameter defined elsewhere in this XML body within the
respective multiRef construction, with id0 as its reference identifier.
The list of parameters with reference idenfifier id0:
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:AuthToken" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="urn:DomainServices">
<accountId xsi:type="xsd:int">0</accountId>
<login xsi:type="xsd:string">www_user</login>
<password xsi:type="xsd:string">somepasswd</password>
<role xsi:type="ns2:Role" xsi:nil="true"/>
</multiRef>
where:
- multiRef id="id0" - defines the list of parameters refered to as id0
- xsi:type="ns2:AuthToken" - the multiRef's Bean type
Fields are defined in the same way as the operation's parameters.
multiRefs can be nested.
Special Beans: AuthToken
H-Sphere XML API includes several special Beans.
AuthToken is a Bean used for authentication.
It defines the following parameters: accountId (int), login (string), password (string),
and role (Role).
System authentication is performed with login and password.
- If accountId == 0, the system tries to choose the user's account.
If the user has more than one account, the system responds with the respective fault message.
- If accountId <> 0, the system tries to load the account with that accountId.
If role is not empty, the system tries to drop permissions based on the values of the role parameter.
Example:
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:AuthToken" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:DomainServices">
<accountId xsi:type="xsd:int">0</accountId>
<login xsi:type="xsd:string">wwwgrinia</login>
<password xsi:type="xsd:string">grinia</password>
<role xsi:type="ns2:Role" xsi:nil="true"/>
</multiRef>
The Role parameter enables operating under a user identity different from the admin account.
If the account has admin privileges, the system will try to switch to the Role user,
and the accountId defined in the role tag will be regarded as the user identity.
If accountId is 0, system will check if the user has only one account, and will operate under that account.
Example:
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns2:AuthToken"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="urn:MailServices">
<accountId xsi:type="xsd:int">0</accountId>
<login xsi:type="xsd:string">admin</login>
<password xsi:type="xsd:string">adminpwd</password>
<role href="#id1"/>
</multiRef>
<multiRef id="id1" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:Role" xmlns:ns3="urn:MailServices"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<accountId xsi:type="xsd:int">0</accountId>
<login xsi:type="xsd:string">wwwgrinia</login>
</multiRef>
Error Messages (SOAP Fault)
A standard error response in H-Sphere XML API looks like:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>Response from registrar server: null:-2008</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Here:
- soapenv:Fault - container for the error response;
- faultcode - method where the error occured;
- faultstring - error message;
- detail - error details.
|