H-Sphere XML API is an experimental feature. Please be careful in using it for critical tasks!
Enabling XML API
To enable XML API in H-Sphere:
Log into the CP server as the cpanel user.
H-Sphere 2.4.3 Patch 11 and up: Edit the ~cpanel/shiva/psoft_config/allow_access.properties file to grant access to CP server via SOAP port from external IPs.If the file does not exist, SOAP access is blocked for all IPs.
[-] SOAP access in earlier H-Sphere versions
Important: In H-Sphere before 2.4.3 Patch 11 SOAP access to CP server via standard 8080 port was provided by default.
The following procedure explains how to configure SOAP access via port 8180 and should not be performed in H-Sphere 2.4.3 Patch 11 and up!
- Copy the wsdd config file:
cp ~cpanel/shiva/psoft/hsphere/axis/server-config.wsdd ~cpanel/hsphere/WEB-INF/Skip this step if the file is already in the target location.
- Edit the Tomcat XML configuration file:
- Find the following commented fragment:
<!--Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" /-->and replace it with the following code:
<Connector port="8180" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" acceptCount="100" debug="0" connectionTimeout="20000" disableUploadTimeout="true" />Optionally, leave the port at 8080.
- Copy the wsdd config file:
After that, XML API will be available. You may wish to test if it works correctly by means of our test Java classes that use H-Sphere XML API.
Testing HS XML API
- Make sure you are logged into the CP server as the cpanel user.
- Download the latest version of test Java classes from PSoft site to the ~cpanel/shiva/psoft/hsphere/axis/test
directory (create it first if it does not exist):
- Extract the archive with the command:
tar zxf AxisExamples.tgzJava source .java files will be added into the current ~cpanel/shiva/psoft/hsphere/axis/test/ directory.
- Edit the necessary test classes (at least AdminServicesTest.java)
replacing URL in the folowing line:
String endpoint = "http://localhost:8080/psoft/servlet/AdminServices.jws";with your URL:String endpoint = "http://your_cp_host:8180/your_cp_url_path/AdminServices.jws";where your_cp_url_path is by default psoft/servlet but you may change it in your Tomcat configuration.
If you have enabled XML API with port 8180, make sure it is specified in the URL.
- Compile Java classes:
- Upon the successful compilation, run the following command:
java psoft.hsphere.axis.test.AdminServicesTest admin <hs_admin_password>
- You will see the > prompt. Here, enter the line:
searchbydomainname domain-namewhere domain-name is a customer's domain name.
- On the next > invitation, press Enter to force the service to run.
- Repeat the previous two steps testing other services, for instance
getAccounts, getDomains, searchbydomainname, etc:
[cpanel@exampleuser test]$ java psoft.hsphere.axis.test.AdminServicesTest admin adminSee H-Sphere XML API Reference in HTML or PDF format to learn how to invoke other Web services via XML interface.
- Press CTRL-D to stop.
Getting the List of Available Services
You may get the list of available XML services by typing in your browser:
your_cp_host is your CP host domain (CP_HOST in hsphere.properties), and
your_cp_url_path is usually psoft/servlet if not configured otherwise in your Tomcat configuration.
If this doesn't work, check servlet mapping in your Tomcat configuration:
- As the cpanel user, open the
~cpanel/hsphere/WEB-INF/web.xml file for edition:
- Make sure the following lines are present in the file:
- Find the following mapping block:
<servlet-mapping>and add the following lines right underneath:
- Restart H-Sphere
- Try again this URL in your browser:
You may also wish to test AxisTestServlet from the package of
test Java classes:
You can generate WSDL files for H-Sphere XML API services by means of the Axis' org.apache.axis.wsdl.Java2WSDL utility.
For example, to generate a WSDL file for SupportServices, log into CP server as cpanel and run:
Example: H-Sphere XML API signup form implementation in PHP 5 (SOAP client embedded) via WSDL.