This article offers an overview of MachPanel API - SOAP API (latest version) and how it works.
Applies to & Supported in MachPanel v5.1.10 and onwards. (
Click Here to see release notes and update instructions)
Current Version of MachPanel API is v5.12 (Download latest API Class Library Documentation below)
MachPanel API facilitates the providers and/or resellers to completely customize the online web store for the services they offer to their customers.
You can set up your own store to interact with your deployment of MachPanel Control Server system and manage the highlighted parts of the panel from the set up store.
If you intend to customize your Online store front website and want to invest on some programming skills and efforts, take the advantage services and functionality offered by MachPanel API.
- Customer Registration
- Customer/Reseller Authentication
- Service Subscription functionality
- Shared Hosting Subscription
- Domain Registration/Transfer
- SSL Certificates
- Misc/Reseller Hosting
- Licensed based services
- VPS Hosting(Hyper-V)
- SaaS Enabled Hosting
- CRM Hosting
- Exchange Hosting
- SharePoint Hosting
- Lync Hosting
4. Service management functionality
MachPanel API is basically a web service which uses SOAP messages to communicate to the Control Server and the client application. The service is hosted on same server as Control Server and same Port as Control Server. The URL of the service is as
http://cpaddress/webservices/machpanelservice.asmx
https://cpaddress/webservices/machpanelservice.asmx
To start communication with the control server through API, first we need the API to be enabled by the provider and/or reseller under whose authority the requests will be entertained. The API needs to be enabled by the provider and/or reseller from within the Control Panel after login.
The snapshot below highlights the navigation path for MachPanel API Settings:
Allowed IP Addresses: If you apply the IP restriction by putting some IP in
Allowed IP Addrersses field of MachPanel API settings.
All the requests to the API shall be from the IPs which are mentioned in
the ‘
Allowed IP Addresses’ input box of MachPanel API settings. The requests
coming from the addresses other than mentioned in the field described
will not be entertained and authentication of the request will fail the
same way.
Every request for an operation through MachPanel API is authenticated with the provided credentials by the client application. These credentials are saved through Control Server as shown above. Only the authenticated request of an operation is entertained, otherwise an “
AuthenticationException” is thrown.
Following is a sample code snippet to utilize MachPanel API in client application to authenticate a customer:
Code Snippet
MPAuthenticationHeader header = new MPAuthenticationHeader();
header.UserName = ConfigurationManager.AppSettings["CompanyLogin"]
header.UserPassword = ConfigurationManager.AppSettings["CompanyPassword"];
MachPanelService svc = new MachPanelService();
svc.MPAuthenticationHeaderValue = header;
ResponseArguments Args = svc.AuthenticateCustomer(“user@domain.com”, “password”, false);#endregion
<
Here you can see a header has been added to the request of a service and this header is mandatory for each and every operation which is performed through MachPanel API.
Another thing to note here is that most of the operations performed through MachPanel API will result a ResponseArguments object. This object will contain a flag for either the operation was successful or not, related message in case of failure and also sometimes an associated key (such as CustomerId and etc.)
Following is a code snippet to List all/filtered existing subscriptions of the customers.
Code Snippet
private void FillSubscriptions()
{
MachPanelService svc = new MachPanelService();
svc.Url = ServiceUrl;
svc.MPAuthenticationHeaderValue = MPHeader;
SubscriptionInfo[] subsList = svc.GetAllSubscriptions();
Lv_Subscriptions.DataSource = subsList;
Lv_Subscriptions.DataBind();
}
//SubscriptionCriteria is a type to get filter criteria from client application
//Assign values to the members/properties by which you want to filter the subscription records
//and leave others unassigned.
private void FillFilteredSubscriptions(MPService.SubscriptionCriteria SC)
{
MachPanelService svc = new MachPanelService();
svc.Url = ServiceUrl;
svc.MPAuthenticationHeaderValue = MPHeader;
SubscriptionInfo[] subsList = svc.GetSubscriptionsByCriteria(SC);
Lv_Subscriptions.DataSource = subsList;
Lv_Subscriptions.DataBind();
}
//you can call above functions in your client application as
//SubscriptionCriteria SC = new SubscriptionCriteria();
//SC.PackageTypeId = 16;
//FillFilteredSubscriptions(SC); OR
//FillSubscriptions();
<
<
Following is a code snippet to Cancel/Suspend/Resume an existing subscription of a customer
Code Snippet
MachPanelService MPSvc = new MachPanelService();
MPSvc.MPAuthenticationHeaderValue = MPHeader;
ResponseArguments Args = null;
ServiceActions action = new ServiceActions();
string Comments = string.Empty;
//Select action as any of the following
//action = ServiceActions.Cancel;Comments = "Cancel subscription via API";
//OR
//action = ServiceActions.Suspend; Comments = "Suspend subscription via API";
//OR
//action = ServiceActions.Resume; Comments = "Resume subscription via API";
Args = MPSvc.UpdateSubscriptionStatus(HostingId, HostingTypeId, action, Comments, false);
<
<
*Please refer to the link on top in references section.
Save
Save
Save