Solution To Series Of Problems When Using "Test Web Services" Page.

20 views
Skip to first unread message

Joshua

unread,
Mar 7, 2010, 8:49:24 PM3/7/10
to RISE
I spent the weekend trying to reverse engineer the cause of my
problems using the "Test Web Services" Page.
I was finally able to track down the problem, which can be resolved,
but only by changing a few characters in the auto-generated PHP code.

It seems that in your generated php code you use mysqli::init() where
you should use mysqli_init();

This is causes me to not be able to use the "Test Web Services" page
in the RISE Editor.

P.S. The "Multiple Root Nodes" problem, seems to be related to a
missing prefix.config.php file!
It was a silly mistake on my part, I originally generated my PHP files
to one folder, where I had created a config file, but subsequently
decided to generate them to a different folder, and neglected to
transfer the config file along with. You might want to consider
improving your error messages, or providing a step-by-step guide for
PHP users.

Ambiguous Messages:

If the prefix.config.php file is missing or in the wrong folder the
message you get from the "Test Web Services Page" is:
"There are multiple root elements. Line 2, position 2."

If the file is present but the information in it is incorrect, then
you get the message:
Bad Gateway

If the file is present and correct, but you are using a version of PHP
more recent than 5.0.0 then you get:
The remote server returned an error (500) Internal Server Error.
(which - for me - is because of "mysqli::init()")

If the mysqli::init() is changed to mysqli_init()
Then it will work for my modern (5.3) PHP implementation.

http://stackoverflow.com/questions/2398728/non-static-method-mysqliinit-cannot-be-called-statically

Joshua

unread,
Mar 8, 2010, 4:09:36 AM3/8/10
to risee...@googlegroups.com, jo...@risetobloome.com
When attempting to use the Generated PHP code from the RISE Editor, I
encounter another problem.
The problem seems to be that the sequence of the parameters in the Prepared
Statement, don't match that of the Bind.
I have tried refactoring, refreshing the interfaces, saving and re-importing
the model, deleting the entity and recreating it.
Each time the parameters seem to appear in a new but random order.
The random order wouldn't pose a problem, except that the random order is
not consistent across the routine.
Here is the code, then the relevant discrepancies appear at the bottom:

Auto-generated PHP:
public function NewParameter($InterfaceID, $Name, $Type, $Description,
$Sequence)
{
if(is_null($InterfaceID))
throw new Exception('ArgumentNullException: InterfaceID');
if(is_null($Name))
throw new Exception('ArgumentNullException: Name');
if(is_null($Type))
throw new Exception('ArgumentNullException: Type');
if(is_null($Description))
throw new Exception('ArgumentNullException: Description');
if(is_null($Sequence))
throw new Exception('ArgumentNullException: Sequence');
$sql_stmt = 'INSERT INTO "t_SR_u_Parameter"("c_u_Name", "c_u_Type",
"c_u_Description", "c_u_Sequence", "c_r_Interface") VALUES (?, ?, ?, ?, ?)';
$mysqli_stmt = $this->ConnectionResource->prepare($sql_stmt);
if($mysqli_stmt===FALSE)
throw new Exception($sql_stmt.': prepare statement failed:
'.$this->ConnectionResource->error);
try
{
if(!$mysqli_stmt->bind_param('isssi', $InterfaceID, $Name, $Type,
$Description, $Sequence))
throw new Exception('Bind parameters failed: '.$mysqli_stmt->error);
if(!$mysqli_stmt->execute())
throw new Exception($sql_stmt.': '.$mysqli_stmt->error);
$mysqli_stmt->close();
}
catch(Exception $e)
{
$mysqli_stmt->close();
throw $e;
}
$sql_stmt = 'SELECT LAST_INSERT_ID()';
$mysqli_stmt = $this->ConnectionResource->prepare($sql_stmt);
if($mysqli_stmt===FALSE)
throw new Exception($sql_stmt.': prepare statement failed:
'.$this->ConnectionResource->error);
try
{
if(!$mysqli_stmt->execute())
throw new Exception($sql_stmt.': '.$mysqli_stmt->error);
if((!$mysqli_stmt->store_result())||(!$mysqli_stmt->bind_result($rv)))
throw new Exception('Unable to store or bind results of query:
'.$mysqli_stmt->error);
$mysqli_stmt->fetch();
$rv = ((int)$rv);
$mysqli_stmt->close();
}
catch(Exception $e)
{
$mysqli_stmt->close();
throw $e;
}
return $rv;
}


// The Problem - Taken From Above:
// Parameter Order: Name, Type, Description, Sequence, Interface
$sql_stmt = 'INSERT INTO "t_SR_u_Parameter"("c_u_Name", "c_u_Type",
"c_u_Description", "c_u_Sequence", "c_r_Interface") VALUES (?, ?, ?, ?, ?)';

// Parameter Order: Interface, Name, Type, Description, Sequence
if(!$mysqli_stmt->bind_param('isssi', $InterfaceID, $Name, $Type,
$Description, $Sequence))

This causes an invalid foreign key error.

Please let me know if there is a workaround for this problem.

Joar Swenning

unread,
Mar 8, 2010, 5:35:02 AM3/8/10
to RISE
Hi Joshua,
I'm sorry about the troubles with the PHP generation. Our intention
was to use ODBC for the PHP code generator as well but, unfortunately
there was at that time a major bug in it, so we had to make a specific
solution instead. We will research the present status for the ODBC for
PHP to see if it is time for an ODBC for PHP-code generator now.

We are investigating all of these problems and will get back in this
forum as soon as we have a solution ready for use.

If you encounter any other problems with it, please, let us know. Your
feedback is very valuable to us!

Best regards,
Joar

Reply all
Reply to author
Forward
0 new messages