| The Cube Panelīs API 2.2 Reference Guide: Accessing Cube Panel's WebServices | ||
|---|---|---|
| Prev | Chapter 1. Introduction | Next |
To begin to use Cube Panel's access library with .NET, follow these steps:
Download the access library. Download here.
In the Visual Studio project, click on Project/Add reference...
Select from the .NET menu, System.Web.Services
Add the CubeWS.dll library by clicking on explore and find the library
This class provides access to the other classes of Cube Panelīs WebServices. Its constructor has the following definitions:
WSUser user = new WSUser(user_name, password, server, port, id_language)
user_name : username with the maximum privileges with which the WebServices will be accessed
password : user password
server : IP/Name of Cube Panel Server
port : Cube Panel access port (default 25112)
id_language : desired Language ID for the WebServices responses
Once a WSUser class request is obtained, the WebServices can be directly used with the following:
Other users can be added after the first request with the getUser method. You only have to use the username as a parameter; see the following example:
Once a WSUser class request is obtained with the necessary credentials, there are two ways to access the WebServices: using the methods provided by the class, or with the execute method.
It is recommended that you access through the methods provided by your own class. A method is provided for each of Cube Panel's APIīs WebServices. However, if you prefer to access through the execute method, use these definitions:
public object []execute(string method, object []params)
method : the name of the WebService being accessed
params : array with the WebService parameters
The following example demonstrates the recommended method of accessing WebServices:
using CubeWS;
class Prueba
{
[STAThread]
static void Main(string[] args)
{
// Init access objects
WSUser admin = WSUser("admin","123456","hostinglinux.com",25112,0);
WSUser client = admin->getUser("client"); // Server administrator
WSUser domain = client->getUser("testdomain1.com"); // testdomain1.com must belong to client
WSUser domain = admin->getUser("testdomain2.com"); // it also allowed
// Get client list (must be called by admin)
ClientInfo []cinfo = admin.ADMINCLIENTS_getClients("",null,"");
// Get client domains (must be called by a client)
DomainInfo []dinfo = client.DOMAINS_getDomains(0,"",null,"");
// Get domain FTP accounts (must be called by a domain)
FTPUserInfo []ftuser = user.FTP_listUsers("",null,"");
}
}