• 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

please help with SOAP request

A

anton1980

Guest
hi guys!

i am trying to do a SOAP request to create a user account and get an error message... i am using PHP. below you can see my request variable.

$soap_request = "
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
<soap:Header>
<CredentialsSoapHeader xmlns=\"http://swsoft.com/webservices/sb/4.0/SystemService\">
<Login>$sb_username</Login>
<Password>$sb_password</Password>
</CredentialsSoapHeader>
</soap:Header>
<soap:Body>
<CreateAccount xmlns=\"http://swsoft.com/webservices/sb/4.0/AccountService\">
<ownerAccountId>1</ownerAccountId>
<username>$username</username>
<password>$password</password>
<firstName>$client_fname</firstName>
<lastName>$client_lname</lastName>
<email>$client_email</email>
<role>SiteOwner</role>
<planId>8</planId>
<changePasswordAllowed>true</changePasswordAllowed>
</CreateAccount>
</soap:Body>
</soap:Envelope>
";

the error i get is this:

HTTP/1.1 500
Date: Fri, 02 Nov 2007 18:47:12 GMT
Server: Apache/1.3.39 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.7 mod_ssl/2.8.30 OpenSSL/0.9.7a
X-Powered-By: PHP/5.2.1
Content-Length: 278
Connection: close
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Bad Request</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


thank you for any help you can offer...
 
Looks like problem with a transport. You can use PHP code samples as described in the Integration guide - http://download1.swsoft.com/Sitebuilder/4.0.0/doc/admin/en_US/sitebuilder-4.0-dev-guide/index.htm
If you try to perform requests manually, you must use POST method and don't forget to include correct SOAP-Action and Content-Length headers.

Example of call using telnet is below. May be this can help you.

[root@XXXX ~]# telnet sb3-dev.XXXXX 80
Trying 10.58.XXXXX...
Connected to sb3-dev.XXXXXX.
Escape character is '^]'.
POST /ServiceFacade/SystemWebService.asmx HTTP/1.1
Host: sb3-dev.XXXXXX
Content-Type: text/xml; charset=utf-8
Content-Length: 520
SOAPAction: "http://swsoft.com/SiteBuilder/SystemService/v_3_2/GetVersionSiteBuilder"

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://swsoft.com/SiteBuilder/SystemService/v_3_2">
<SOAP-ENV:Header>
<ns1:CredentialsSoapHeader>
<ns1:Login>admin</ns1:Login>
<ns1:password>admin</ns1:password>
</ns1:CredentialsSoapHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetVersionSiteBuilder xmlns="http://swsoft.com/SiteBuilder/SystemService/v_3_2"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

HTTP/1.1 200 OK
Date: Fri, 02 Nov 2007 10:30:00 GMT
Server: Apache/2.0.51 (Fedora)
X-Powered-By: PHP/5.1.2
Set-Cookie: SessionID=3d10c7dd472afc2950d83; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 484
Connection: close
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://swsoft.com/SiteBuilder/SystemService/v_3_2"><SOAP-ENV:Body><ns1:GetVersionSiteBuilderResponse><ns1:GetVersionSiteBuilderResult><ns1:Major>4</ns1:Major><ns1:Minor>1</ns1:Minor><ns1:Build>svn.r25921</ns1:Build><ns1:Revision>25921</ns1:Revision></ns1:GetVersionSiteBuilderResult></ns1:GetVersionSiteBuilderResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Connection closed by foreign host.
 
Thank you very much for your response! It helped. I now get a different error. My request variable is this:

$soap_request = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"http://swsoft.com/SiteBuilder/SystemService/v_3_2\">
<SOAP-ENV:Header>
<ns1:CredentialsSoapHeader>
<ns1:Login>$sb_username</ns1:Login>
<ns1:password>$sb_password</ns1:password>
</ns1:CredentialsSoapHeader>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetVersionSiteBuilder xmlns=\"http://swsoft.com/SiteBuilder/SystemService/v_3_2\"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";

The error I get is...

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring>Procedure 'GetVersionSiteBuilder' not present</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

If you can offer an advice - I will greatly appreciate it. Thank you!
 
This problem often occurs then namespace is wrong.

As I can see in your first post, you're trying to use web services facade v.4.0.0, but I give the example of call to web services facade v.3.2.0. Both of these web services facades are supported by SB 4.0.0. Different facades have different namespaces and locations.

Web services facade v.3.2.0:
* located at http://<sb-host>/ServiceFacade/<WebServiceName>.asmx
* namespaces: http://swsoft.com/SiteBuilder/<WebServiceNamespaceName>/v_3_2

Web services facade v.4.0.0:
* located at http://<sb-host>/ServiceFacade/4.0/<WebServiceName>.asmx
* namespaces: http://swsoft.com/webservices/sb/4.0/<WebServiceNamespaceName>

So you must correct the requested URL of web service or namespace (also don't forget to fix SOAP-Action header).
 
Thank you for your help, but nothing I tried works... I guess I will just fake-browse it to create accounts, as usual.
 
I am having a similar issue with regards to importing a large amount of users into Sitebuilder. I am presently trying to import a large group of teachers into the Sitebuilder database to allow them to make a somewhat "dummy-proof" website. I've already figured out the script to get these people into Plesk through command-line.

/usr/local/psa/bin/webuser --create user -domain host.clay.k12.fl.com -passwd changeme -asp true -php true -ssi true -cgi true -perl true -python true -fastcgi true -quota

If only SiteBuilder were that straightforward ><. I've had zilch for exposure to SOAP, so I wouldn't know where to begin. Based on what i've read in the Wiki, it's a protocol used to remotely access applications. It's very similar in format to XML.. blah blah... documentation on this part of the product stinks. I need to take a delimited file and import the contents of it into the SiteBuilder database. Whether I need to do this in PHP, PERL, or what, a good solid example would greatly help.

I have put in a ticket on this, and the only reply I get is read
http://download1.swsoft.com/Sitebuilder/4.0.0/doc/admin/en_US/sitebuilder-4.0-dev-guide/index.htm
http://download1.swsoft.com/Sitebuilder/4.0.0/doc/admin/en_US/sitebuilder-4.0-dev-guide/41564.htm

Of which, I get a :"You don't have permission to access /Sitebuilder/4.0.0/doc/admin/en_US/sitebuilder-4.0-dev-guide/41564.htm on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request." When I try to access documents in the doc/admin folder...

There's some great support... and that's from paid support...

Folks, if there's anyone out there that can give me some insight as to how to get this done, I would greatly appreciate anything anyone is willing to lend.

Thanks.
 
Hey Sib,

Thank you for the update - the document it exactly where you linked. I've been through that document previously before they had moved it, and copy / pasted the exact code into the editor I use (including the PHP classes). I modified:

$serviceUrl='http://sitebuilder.webhost.clay.k12.fl.us/ServiceFacade/4.0/';

$serviceLogin = 'admin';
$servicePassword = 'changeme';
$struct->username = 'bob';
$struct->password = 'password';
$struct->firstName = 'Bob';
$struct->lastName = 'Jones';
$struct->email = '[email protected]';
$struct->role = 'Site Owner';
$struct->planId = 2;
$struct->changePasswordAllowed = 'true';

PHP:
<?php
class Utils_SoapClient extends SoapClient {

protected $_targetNamespace;

public function __construct($wsdl, $options){ 

parent::__construct($wsdl, $options);

// detect target namespace

$xml = simplexml_load_file($wsdl);

$this->_targetNamespace = (string) $xml['targetNamespace'];

}
public function setCredentialsHeader($login, $password) {

$header = new SoapHeader($this->_targetNamespace,

'CredentialsSoapHeader',

new SoapVar(

array(

'Login' => $login,

'Password' => $password,

),

SOAP_ENC_OBJECT,

'CredentialsSoapHeader',

$this->_targetNamespace

)

);


$this->__setSoapHeaders(array($header));

}


}

$serviceUrl = 'http://sitebuilder.webhost.clay.k12.fl.us/ServiceFacade/4.0/';
$serviceLogin = 'admin';
$servicePassword = 'changeme';
$accountService = new Utils_SoapClient($serviceUrl.'/AccountWebService.asmx?WSDL', array());
$accountService->setCredentialsHeader($serviceLogin, $servicePassword);
$struct = new stdClass();
$struct->username = 'bob';
$struct->password = 'password';
$struct->firstName = 'Bob';
$struct->lastName = 'Jones';
$struct->email = '[email protected]';
$struct->role = 'Site Owner';


$result = $accountService->CreateAccount(new SoapVar($struct, SOAP_ENC_OBJECT));

$accountId = $result->UserAccount->AccountId;

?>

to reflect the admin login for my server and it's password. The other fields I modified to reflect the appropriate user settings and used "Site Owner" (case specific) as a role.

Now here's where my ignorance shines through *grin*... the documentation says zilch about where to place this request, what format to save it in, how to call it, etc... I've tried running it from a commandline like you would a normal PHP script ex: ./PHP5 /root/Desktop/scripts/importusers.php and it bombs horribly with a good list of errors. When I save the file as a PHP document and place it in the /ServiceFacade/4.0/ directory, I get "no input file specified".

I see no where in the script that it calls to open a file (which is what I REALLY need to be able to do) and stream it into this SOAP request. Judging by their sample script, and my extremely limited knowledge of SOAP (even after reading through pages and pages of their documentation), I've replaced all of the variables I should need to replace in order to import what appears to be a single user - not an import file full of users. I need someone to tell me where i'm going wrong. I'd like to do this request through PHP, as it seems to be the easiest method to do this with. Can anyone give me an idea on where to start please. This is a project I absolutely have to have done before Friday morning, and i've been fighting with this product for weeks :(

Also, about this line "$this->_targetNamespace = (string) $xml['targetNamespace'];" does 'targetNamespace' have to be defined as 'http://swsoft.com/webservices/sb/4.0/SystemService'? I've tried that in that as well, and have gotten the same error message that 'No Input File Specified'. I see the $wsdl variable, and it looks to be calling a file... but no were in the previous lines does it define which file, where it should exist, and how it should be formatted to be able to be imported.

Thanks in advance...
 
You must fix in your script the user role name:
$struct->role = 'SiteOwner';

User role name is "SiteOwner", not "Site Owner".
Also, you must define the plan for user. Yuo must create the plan and then got it UUID. The correct way to get the UUID of the plan is to use methods from PlanWebService. But for simplification you can find the UUID directly in the database.
Output of my console is below:
[root@sb-svn ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 89210 to server version: 5.0.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> use sitebuilder3;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select name, uuid from plan;
+------+--------------------------------------+
| name | uuid |
+------+--------------------------------------+
| Root | 8d0e1367-06f1-5fd1-5242-58d641a9571b |
| test | 9827254b-6978-7ab0-5839-b330364555d1 |
+------+--------------------------------------+
2 rows in set (0.01 sec)

So I want to use plan 'test', and it's UUID is 9827254b-6978-7ab0-5839-b330364555d1.

I must add the following line:
$struct->planId = '9827254b-6978-7ab0-5839-b330364555d1';

You can run the script by the following line:
/opt/php52/bin/php5 /path/to/your/script.php
 
Back
Top