• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

sitebuilder API CreateSite2 problem

J

JR Gould

Guest
Hello,

I have been toying around with the sitebuilder API though I am currently running stuck on an issue that the documentation does not seem to cover.

I have installed and configured the sitebuilder properly ( made a default plan, setup the configuration, note that when making accounts manually, it DOES work perfectly )

Now we are trying to create a scenario where new customers will automatically get a hosting account and a sitebuilder configured to connect only to that hosting account.

to achieve just that, I use the following piece of code in PHP:

$serviceUrl = 'http://sitebuilder.somedomain.nl/ServiceFacade/4.5/';
$serviceLogin = 'admin';
$servicePassword = 'xxxxx';

//Create account
$accountService = new Utils_SoapClient($serviceUrl.'/AccountWebService.asmx?WSDL', array());
$accountService->setCredentialsHeader($serviceLogin, $servicePassword);
$struct = new stdClass();
$struct->username = strtolower($rows['Username']);
$struct->password = $rows['Password'];
$struct->firstName = $rows['Initials'];
$struct->lastName = $rows['SurName'];
$struct->email = $rows['EmailAddress'];
$struct->role = 'SiteOwner';
$struct->planId = 2;

try
{
$result = $accountService->CreateAccount(new SoapVar($struct, SOAP_ENC_OBJECT));
$accountId = $result->UserAccount->AccountId;
}
catch(Exception $e)
{
echo 'Exceptions can be investigated but are usually not serious bugs!'."\n";
echo 'Caught exception: ', $e->getMessage(), "\n";

}

unset($struct);

//Get the host ID
//Only used once to obtain the hosting ID
/**
$hostService = new Utils_SoapClient($serviceUrl.'/HostWebService.asmx?WSDL', array());
$hostService->setCredentialsHeader($serviceLogin, $servicePassword);
$struct = new stdClass();
$struct->address = 'server02.somedomain.nl';

$result = $hostService->GetHostByAddress(new SoapVar($struct, SOAP_ENC_OBJECT));
$hostinfo = $result->GetHostByAddressResult;

print_r($hostinfo);

echo"<br/>\n";**/

unset($struct);
//Add website to account
$siteService = new Utils_SoapClient($serviceUrl.'/SiteWebService.asmx?WSDL', array());
$siteService->setCredentialsHeader($serviceLogin, $servicePassword);
$struct = new stdClass();
$struct->siteType = 'Regular';
$struct->siteAlias = $rows['Domain'] ;
$struct->ownerId = $accountId;
$struct->publishingSettings = new stdClass();
$struct->publishingSettings->Id = '1';
$struct->publishingSettings->Mode = 'Ftp';
$struct->publishingSettings->StandardLocation = new stdClass();
$struct->publishingSettings->StandardLocation->Address = 'ftp://'.$rows['Domain'];
$struct->publishingSettings->StandardLocation->UserName = strtolower($rows['Username']);
$struct->publishingSettings->StandardLocation->Password = $rows['Password'];
$struct->publishingSettings->StandardLocation->WorkingDirectory = '/www/';
$struct->publishingSettings->StandardLocation->WebSiteUrl = 'http://'.$rows['Domain'].'/';
$struct->publishingSettings->StandardLocation->IsAnonymous = 'false';
$struct->publishingSettings->StandardLocation->Veid = 0;
$struct->publishingSettings->StandardLocation->VerifyStatus = 'Unverified';
$struct->publishingSettings->StandardLocation->LastVerifyAttempt = '0000-00-00 00:00:00';
$struct->publishingSettings->StandardLocation->FallbackIP = '192.0.2.1';
$struct->publishingSettings->StandardLocation->HostId = '90fa7755-28ac-e50c-6f6d-9004795f78d5';

try
{
$result = $siteService->CreateSite2(new SoapVar($struct, SOAP_ENC_OBJECT));
$siteb_id = "'".$result->CreateSite2Result->Id."'";
}
catch(Exception $e)
{
echo 'Exceptions can be investigated but are usually NOT serious bugs!'."\n";
echo 'Caught exception: ', $e->getMessage(), "\n";

}


Now this is pretty much exactly according to the examples given in the API reference.
It also seems to do the job to the extent that it actually "makes" the account + hosting package.
However the hosting account will not be able to publish his site.
This is presumably because of a problem with the hosting ID.

Upon looking in the mysql table I stumble accross these settings which are different from sites I create manually
In the site_publish_settings mysql table the host_id will be set to NULL, as well as the FTP port being set to NULL.
Changing the host_id to 1 and the ftp port to 21 WILL fix this issue.
So í'm considering a "hack solution" where I just connect to mysql to correct this manually, though i'd simply prefer the sitebulder api working.


when I "print_r()" the site object and result in PHP I get the following information:

(* actual regged hosting domain replaced with clientdomain.nl )
//the posted soap object
stdClass Object
(
[siteType] => Regular
[siteAlias] => clientdomain.nl
[ownerId] => 9556afcd-d235-255e-38a2-baefa865650b
[publishingSettings] => stdClass Object
(
[Id] => 1
[Mode] => Ftp
[StandardLocation] => stdClass Object
(
[Address] => ftp://clientdomain.nl
[UserName] => kl010035
[Password] => SomeVisiblePassword
[WorkingDirectory] => /www/
[WebSiteUrl] => http://clientdomain.nl/
[IsAnonymous] => false
[Veid] => 0
[VerifyStatus] => Unverified
[LastVerifyAttempt] => 0000-00-00 00:00:00
[FallbackIP] => 192.0.2.1
[HostId] => 90fa7755-28ac-e50c-6f6d-9004795f78d5
)

)

)
//Result soap object
stdClass Object
(
[Id] => 448a7f12ead535cd721ec0d8030c803c
[Alias] => clientdomain.nl
[OwnerId] => 9556afcd-d235-255e-38a2-baefa865650b
[OwnerUserName] => kl010035
[IsActive] => 1
[PublishingSettings] => stdClass Object
(
[Id] => a2db6683-1170-966c-01aa-b9dcfc3470f0
[StandardLocation] => stdClass Object
(
[Address] =>
[UserName] => kl010035
[Password] =>
[WorkingDirectory] => /www/
[WebSiteUrl] => http://clientdomain.nl/
[IsAnonymous] =>
[Veid] => 0
[VerifyStatus] => Unverified
[LastVerifyAttempt] => 1970-01-01T01:00:00+01:00
[FallbackIP] => 192.0.2.1
[HostId] => 00000000-0000-0000-0000-000000000000
)

[Mode] => Ftp
)

[HostId] => 00000000-0000-0000-0000-000000000000
[ResellerId] => 00000000-0000-0000-0000-000000000000
[ResellerUserName] => admin
[CreationDate] => 2009-03-08T16:28:26+01:00
)

It seems clear that it's not getting the proper HostId set.
Now i've tested this and It does not actually matter what ID i fill in as host ID (even one that really exists) its not returning any valid hosting number)

i've tried toying around with the 'VerifyStatus' and 'Address' fields but with little luck.
(note that there are only 2 other accounts in there at this time, im aware of possibility of overlapping IDs)

The weird thing is, if I actually login through the admin panel and browse to the user's site that was created and click "verify location" it WILL actually verify!
(upon checking the database, publishing_settings, the field host_id will have become 1 and the FTP port 21, this is all that changes).
I'm beginning to suspect a bug in the sitebuilder code.

now my questions are:

1. Is there any step I might have missed, anything wrong with my code that stands out?

2. What number should the "publishing ID" (id) be ? unique? non-unique? (this is covered no where)

3. What kind of number should the "hosting ID" (hostID) be? in the example they use the number '12', this seems incorrect?

4. The 'address' field is considered deprecated, what should i put in there instead? why is it still being used as it is in your examples?
 
This is definitely a bug in Sitebuilder API...

I see that this is reported 8 months ago and still not fixed..??

How long does it usually take for a bug in Sitebuilder to be fixed?

Is there some other way to report bugs, or it's enough to be reported here on this forum?
 
Hi JR Gould

I am very new at Sitebuilder. I have exactly the same problem as Soap doesn't work properly for creating a site. The host_id and port are NULL and the site can not be published until I manually save the publishing settings from the control panel.

Could you please advise if you have any ideas to resolve this problem?

Thanks in advance.

Harry
 
Resolved

Hi JR Gould

I am very new at Sitebuilder. I have exactly the same problem as Soap doesn't work properly for creating a site. The host_id and port are NULL and the site can not be published until I manually save the publishing settings from the control panel.

Could you please advise if you have any ideas to resolve this problem?

Thanks in advance.

Harry

This issue has been resolved. Login to Sitebuilder Admin panel.

Users > Plans > Publishing Settings

Must tick 'Allow users to modify publishing settings'.

That's it.

Thanks
 
Resolved

Hi All

This issue has been resolved. Please login to Sitebuilder Admin panel.

1. Go to Manage Plans
2. Click a Plan Name
3. Click Publishing Settings
4. Tick 'Allow users to modify publishing setting'

That's it.

Missing 'Hostid' and 'FTP Port' won't be issued as they will be updated from the user panel.

Thanks

Harry
 

Similar threads

K
Replies
1
Views
4K
KemalE
K
N
Replies
3
Views
3K
NicolasR
N
K
Replies
1
Views
2K
kbessinger
K
Back
Top