This section contains examples of using the integration API that are written in ASP language.
To add a host to Plesk Sitebuilder hosts pool, the following steps should be taken:
1. Specify common Sitebuilder preferences.
The preferences are as follows:
dim baseUrl, adminLogin, adminPassword, newAccountId, newSiteId
dim error
baseUrl="http://localhost:2006"
adminLogin="admin"
adminPassword="admin"
2. Specify the ID of a site owner account and the site name. A sample of the properties can look as follows:
HostName ="My new host"
HostAddress ="192.0.2.12"
3. Add code of function CreateHost from the list of core functions. These functions are written on ASP and are used to invoke Plesk Sitebuilder integration API methods.
For list of core functions, click the following link:
functions list.
<%
Function CreateHost(HostName, HostAddress)
Const SMTPPort = 0;
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/HostWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/HostService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreateHost xmlns=""http://swsoft.com/webservices/sb/4.5/HostService"">"
body = body & "<hostName>" & HostName & "</hostName>"
body = body & "<hostAddress>" & HostAddress & "</hostAddress>"
body = body & "<SMTPPort>" & SMTPPort & "</SMTPPort>"
body = body & "</CreateHost >"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
CreateHost=""
else
Set XMLData = XMLDOM.SelectSingleNode("//CreateHostResponse/CreateHostResult/Id")
CreateHost = XMLData.text
end if
else
CreateHost=""
response.Write "Error parsing SOAP response"
end if
end if
End Function
Function CreateAccount (accountName, accountPassword, firstName, lastName, eMail, planId)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/AccountWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/AccountService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreateAccount xmlns=""http://swsoft.com/webservices/sb/4.5/AccountService"">"
body = body & "<ownerAccountId></ownerAccountId>"
body = body & "<username>" & accountName & "</username>"
body = body & "<password>" & accountPassword & "</password>"
body = body & "<firstName>" & firstName & "</firstName>"
body = body & "<lastName>" & lastName & "</lastName>"
body = body & "<email>" & eMail & "</email>"
body = body & "<role>SiteOwner</role>"
body = body & "<planId>" & planId & "</planId>"
body = body & "<changePasswordAllowed>true</changePasswordAllowed>"
body = body & "</CreateAccount>"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
CreateAccount = XMLDOM.xml 'XMLNode.xml
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
CreateAccount=""
else
Set XMLData = XMLDOM.SelectSingleNode("//CreateAccountResponse/UserAccount/AccountId")
CreateAccount = XMLData.text
end if
else
CreateAccount=""
response.Write "Error parsing SOAP response"
end if
end if
End Function
Function TakeOwnerShip(accountId, siteId, siteAlias)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/SiteWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/SiteService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<TakeOwnershipOfAnonymousSite xmlns=""http://swsoft.com/webservices/sb/4.5/SiteService"">"
body = body & "<siteId>" & siteId & "</siteId>"
body = body & "<ownerId>" & accountId & "</ownerId>"
body = body & "<alias>" & siteAlias & "</alias>"
body = body & "</TakeOwnershipOfAnonymousSite>"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
TakeOwnerShip=false
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
else
TakeOwnerShip=true
end if
else
response.Write "Error parsing SOAP response"
end if
end if
End Function
Function ListPlans()
dim url, xmlhttp, XMLDOM, XMLNodeList, x , str
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/PlanWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/PlanService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<GetAvailablePlans xmlns=""http://swsoft.com/webservices/sb/4.5/PlanService"">"
body = body & "<accountId></accountId>"
body = body & "</GetAvailablePlans>"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNodeList = XMLDOM.selectNodes("//PlanValue")
For x = 1 To XMLNodeList.length
str = str & "<option value=""" & XMLNodeList.Item(x - 1).selectSingleNode("PlanId").text & """>" & XMLNodeList.Item(x - 1).selectSingleNode("Name").text
Next
ListPlans=str
End Function
Function CreateSite(ownerId, siteAlias)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/SiteWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/SiteService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreateSite xmlns=""http://swsoft.com/webservices/sb/4.5/SiteService"">"
body = body & "<siteType>Regular</siteType>"
body = body & "<siteAlias>" & siteAlias & "</siteAlias>"
body = body & "<ownerId>" & ownerId & "</ownerId>"
body = body & "</CreateSite >"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
CreateSite=""
else
Set XMLData = XMLDOM.SelectSingleNode("//CreateSiteResponse/CreateSiteResult/Id")
CreateSite = XMLData.text
end if
else
CreateSite=""
response.Write "Error parsing SOAP response"
end if
end if
End Function
Function CreatePlan(PlanName, PlanDescription, PMpagesLimit, PMpagesrootLevel,PMpagesLevel, PMsitesNumber, PMaccountsNumber, PMhostsNumber,PisPersonal, PisAnonymous, PTrialLifeTime, PTrialLifeType,
PTemplatesID, PPageSetsID, PModulesID, PHostsID, PFamiliesID, PDefaultFamilyID, PIsPublishSettingsEditable, PIsFTPPublishAvailable,
PIsXcopyPublishAvailable, PIsVPSPublishAvailable, PIsAdditionalSiteContentAllowed, PAdditionalSiteContent, PIsUserManagementAllowed, PIsSiteManagementAllowed)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/PlanWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/PlanService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreatePlan xmlns=""http://swsoft.com/webservices/sb/4.5/PlanService""> "
body = body & "<name>" & PlanName & "</name>"
body = body & "<description>" & PlanDescription & "</description>"
body = body & "<maxPagesNumber>" & PMpagesLimit & "</maxPagesNumber>"
body = body & "<maxPagesRootLevel>" & PMpagesrootLevel & "</maxPagesRootLevel>"
body = body & "<maxPagesLevel>" & PMpagesLevel & "</maxPagesLevel>"
body = body & "<maxSitesNumber>" & PMsitesNumber & "</maxSitesNumber>"
body = body & "<maxAccountsNumber>" & PMaccountsNumber & "</maxAccountsNumber>"
body = body & "<maxHostsNumber>" & PMhostsNumber & "</maxHostsNumber>"
body = body & "<isPersonal>" & PisPersonal & "</isPersonal>"
body = body & "<isAnonymous>" & PisAnonymous & "</isAnonymous>"
body = body & "<trialLifeTime>" & PTrialLifeTime & "</trialLifeTime>"
body = body & "<trialLifeType>" & PTrialLifeType & "</trialLifeType>"
body = body & "<templatesIds> <string>" & PTemplatesID & "</string></templatesIds>"
body = body & "<pagesetsIds><string>" & PPageSetsID & "</string></pagesetsIds>"
body = body & "<modulesIds> <string>" & PModulesID & "</string></modulesIds>"
body = body & "<hostsIds> <string>" & PHostsID & "</string></hostsIds>"
body = body & "<families> <string>" & PFamiliesID & "</string></families>"
body = body & "<defaultFamily>" & PDefaultFamilyID & "</defaultFamily>"
body = body & "<isPublishingSettingsEditable>" & PIsPublishSettingsEditable & "</isPublishingSettingsEditable>"
body = body & "<isFtpPublishAvailable>" & PIsFTPPublishAvailable & "</isFtpPublishAvailable>"
body = body & "<isXcopyPublishAvailable>" & PIsXcopyPublishAvailable & "</isXcopyPublishAvailable>"
body = body & "<isVpsPublishAvailable>" & PIsVPSPublishAvailable & "</isVpsPublishAvailable>"
body = body & "<isAdditionalSiteContentAllowed>" & PIsAdditionalSiteContentAllowed & "</isAdditionalSiteContentAllowed>"
body = body & "<additionalSiteContent>" & PAdditionalSiteContent & "</additionalSiteContent>"
body = body & "<isUserManagementAllowed>" & PIsUserManagementAllowed & "</isUserManagementAllowed>"
body = body & "<isSiteManagementAllowed>" & PIsSiteManagementAllowed & "</isSiteManagementAllowed>"
body = body & "</CreateHost >"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
CreatePlan=""
else
Set XMLData = XMLDOM.SelectSingleNode("//CreateHostResponse/CreatePlanResult/PlanId")
CreatePlan = XMLData.text
end if
else
CreatePlan=""
response.Write "Error parsing SOAP response"
end if
end if
End Function
Function UpdatePlan(PlanId, PlanName, PlanDescription, PMpagesLimit, PMpagesrootLevel,PMpagesLevel, PMsitesNumber, PMaccountsNumber, PMhostsNumber, PTrialLifeTime, PTrialLifeType,
PTemplatesID, PPageSetsID, PModulesID, PHostsID, PFamiliesID, PDefaultFamilyID, PIsPublishSettingsEditable, PIsFTPPublishAvailable,
PIsXcopyPublishAvailable, PIsVPSPublishAvailable, PIsAdditionalSiteContentAllowed, PAdditionalSiteContent, PIsUserManagementAllowed, PIsSiteManagementAllowed)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/PlanWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/PlanService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreatePlan xmlns=""http://swsoft.com/webservices/sb/4.5/PlanService""> "
body = body & "<planId>" & PlanId & "</planId>"
body = body & "<name>" & PlanName & "</name>"
body = body & "<description>" & PlanDescription & "</description>"
body = body & "<maxPagesNumber>" & PMpagesLimit & "</maxPagesNumber>"
body = body & "<maxPagesRootLevel>" & PMpagesrootLevel & "</maxPagesRootLevel>"
body = body & "<maxPagesLevel>" & PMpagesLevel & "</maxPagesLevel>"
body = body & "<maxSitesNumber>" & PMsitesNumber & "</maxSitesNumber>"
body = body & "<maxAccountsNumber>" & PMaccountsNumber & "</maxAccountsNumber>"
body = body & "<maxHostsNumber>" & PMhostsNumber & "</maxHostsNumber>"
body = body & "<trialLifeTime>" & PTrialLifeTime & "</trialLifeTime>"
body = body & "<trialLifeType>" & PTrialLifeType & "</trialLifeType>"
body = body & "<templatesIds> <string>" & PTemplatesID & "</string></templatesIds>"
body = body & "<pagesetsIds><string>" & PPageSetsID & "</string></pagesetsIds>"
body = body & "<modulesIds> <string>" & PModulesID & "</string></modulesIds>"
body = body & "<hostsIds> <string>" & PHostsID & "</string></hostsIds>"
body = body & "<families> <string>" & PFamiliesID & "</string></families>"
body = body & "<defaultFamily>" & PDefaultFamilyID & "</defaultFamily>"
body = body & "<isPublishingSettingsEditable>" & PIsPublishSettingsEditable & "</isPublishingSettingsEditable>"
body = body & "<isFtpPublishAvailable>" & PIsFTPPublishAvailable & "</isFtpPublishAvailable>"
body = body & "<isXcopyPublishAvailable>" & PIsXcopyPublishAvailable & "</isXcopyPublishAvailable>"
body = body & "<isVpsPublishAvailable>" & PIsVPSPublishAvailable & "</isVpsPublishAvailable>"
body = body & "<isAdditionalSiteContentAllowed>" & PIsAdditionalSiteContentAllowed & "</isAdditionalSiteContentAllowed>"
body = body & "<additionalSiteContent>" & PAdditionalSiteContent & "</additionalSiteContent>"
body = body & "<isUserManagementAllowed>" & PIsUserManagementAllowed & "</isUserManagementAllowed>"
body = body & "<isSiteManagementAllowed>" & PIsSiteManagementAllowed & "</isSiteManagementAllowed>"
body = body & "</CreateHost >"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
Err.Raise 100, "UpdatePlan", XMLData.Text
end if
else
Err.Raise 100, "UpdatePlan", "Error parsing SOAP response"
end if
end if
End function
<%
function RenderSuccess (login, password, siteId)
dim adminUrl, wizardUrl
adminUrl=baseUrl & "/ExternalLogin.ashx?Login=" & login & "&Password=" & password
wizardUrl=adminUrl & "&SiteID=" & siteId
adminUrl=adminUrl & "&ShowAdmin=true"
%>
You have successfully registered. Please <a href="<%=wizardUrl%>">click here</a> to edit your site at Wizard or <a href="<%=adminUrl%>">click here</a> to enter Sitebuilder siteowner's panel.
<%
End function
%>
<%
function RenderForm
%>
<h3>
SAMPLE CODE FOR SITEBUILDER 4.5 FOR WINDOWS INTEGRATION</h3>
Copyright© 2008 by <a href="parallels.com">Parallels Inc</a><br>
NOTE: This code is provided as is, without any warranty, either express or implied
Please do not use this sample in a production environment WARNING! Administrator
credentials are sent in clear text. It is by default assumed that this script will
be run on the same machine as the Sitebuilder installation. In case you want to
administer the Sitebuilder remotely using this Web Service API, make sure to secure
the communication (for example, by using HTTPS protocol instead of HTTP).
<form method="post">
<input type="hidden" name="siteId" value="<% response.Write newSiteId%>" />
<table>
<tr>
<td>
Account Name:
</td>
<td>
<input type="text" name="accountName" value="TestUserFromASP"></td>
</tr>
<tr>
<td>
Account Password:
</td>
<td>
<input type="text" name="accountPassword" value="111111"></td>
</tr>
<tr>
<td>
First Name:
</td>
<td>
<input type="text" name="firstName" value="Bob"></td>
</tr>
<tr>
<td>
Last Name:
</td>
<td>
<input type="text" name="lastName" value="Smith"></td>
</tr>
<tr>
<td>
E-Mail:</td>
<td>
<input type="text" name="eMail" value="none@nowhere.org"></td>
</tr>
<tr>
<td>
Plan:
</td>
<td>
<select name="plan">
<%response.Write ListPlans() %>
</select>
</td>
</tr>
<tr><td colspan="2"><hr /></td></tr>
<tr>
<td>
Site alias:
</td>
<td>
<input type="text" name="siteAlias" value="Test Site">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="action" value="create"></td>
</tr>
</table>
</form>
<%
End function
%>
4. Run the CreateHost function.
NewHostID = CreateHost(HostName, HostAddress)
If the host is successfully added, the host ID value will be written to the NewHostID variable.
For full ASP code sample, click on the following link:
code sample.
<%
dim baseUrl, adminLogin, adminPassword, newAccountId, newSiteId
dim error
baseUrl="http://localhost:2006"
adminLogin="admin"
adminPassword="admin"
HostName ="My new host"
HostAddress ="192.0.2.12"
NewHostID = CreateHost(HostName, HostAddress)
'
'This function is used to add a host to Plesk Sitebuilder.
'
Function CreateHost(HostName, HostAddress)
Const SMTPPort = 0;
dim url, xmlhttp, XMLDOM, XMLNode
'Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.5/HostWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://swsoft.com/webservices/sb/4.5/HostService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreateHost xmlns=""http://swsoft.com/webservices/sb/4.5/HostService"">"
body = body & "<hostName>" & HostName & "</hostName>"
body = body & "<hostAddress>" & HostAddress & "</hostAddress>"
body = body & "<SMTPPort>" & SMTPPort & "</SMTPPort>"
body = body & "</CreateHost >"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
'Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
CreateHost=""
else
Set XMLData = XMLDOM.SelectSingleNode("//CreateHostResponse/CreateHostResult/Id")
CreateHost = XMLData.text
end if
else
CreateHost=""
response.Write "Error parsing SOAP response"
end if
end if
End Function %>