Newstruct() CodeGen PHP XML-RPC interface

Hello,

I’m using ServiceBuilder V5, I have an interface and I also generated to *.inc and included xmlrpc.inc, and also assume that I have putup a webserver.

This is my first time to use xml-rpc interface, I’m trying to consume a webservice from another location and my client is *.php which runs in my webserver.

Base on your Support for XML-RPC (Delphi) (http://wiki.remobjects.com/wiki/Support_for_XML-RPC_(Delphi) )

I got this this error:

Fatal error: Class ‘NewStruct’ not found in C:\sample_intf.inc which I don’t understand ‘NewStruct’ is not listed in my RODL.

Please explain, give me some insights what am I missing, is there any alternative way.

Cheers

Thanks in advance and more power.

Can you give your RODL, please?

Hello slavad here’s the RODL

Thank you for the immediate response. more power

Hi.

I don’t see it. You can send it to support@remobjects.com

Sorry my mistake didn’t notice I can’t attached file. I have send it with subject: For: slavad (MCIS RODL)…

Thanks again

Got it.

Yes, neither your RODL, nor generated .inc file contain 'NewStruct’
Could it be your previous test attempts or something?

Could you post your main .php file here? Or just run text search for ‘NewStruct’ in your projects folder to make sure which file contains it.

Hi,

I already done text search in my intf.pas but not found ‘NewStruct’. BTW here my php code.

<?php require("MCIS_intf.inc"); $server = new xmlrpc_client("http://10.21.20.46:8181/bin"); $message = new xmlrpcmsg('MCISSecurity.AuthenticateUser',array(new xmlrpcval('20217900', 'string'), new xmlrpcval('8010', 'string'))); $result = $server->send($message); if (!$result) { print "

Could not connect to HTTP server.

"; } elseif ($result->faultCode()) { print "

XML-RPC Fault #" . $result->faultCode() . ": " . $result->faultString(); } else { $struct = $result->value(); $serversession = $struct->structmem('AppServerSessionID'); $aSession = $serversession->scalarval(); } $message = new xmlrpcmsg(new xmlrpcmsg("MCISService.GetMember"); $message->addParam(new xmlrpcval('190250336504', "string")); $result = $server->send($message); if (!$result) { print "

Could not connect to HTTP server.

"; } elseif ($result->faultCode()) { print "

XML-RPC Fault #" . $result->faultCode() . ": " . $result->faultString(); } else { $struct = $result->value(); $aProCode = $struct->structmem('ProCode'); $ProCode = $aProcode->scalarval(); ?>

And I don’t know why every class in my structure in my RODL it generates newstruct related function, here’s one example of the result class of the above service called in *.inc

class TRoUserAuthenticationResult {
public $ResultType; // TRoUserAuthenticationResultType
public $Message; // String
public $AppServerSessionID; // String

function TRoUserAuthenticationResult() {}
static function FromXmlRpcVal($n) {
$res = new NewStruct();
$res->ResultType = $n->structmem(“ResultType”)->scalarval();
$res->Message = $n->structmem(“Message”)->scalarval();
$res->AppServerSessionID = $n->structmem(“AppServerSessionID”)->scalarval();
return $res;
}
static function ToXmlRpcVal($data) {
$res = new xmlrpcval();
$arr = array();
$arr[“ResultType”] = new xmlrpcval($data->ResultType, “int”);
$arr[“Message”] = new xmlrpcval($data->Message, “string”);
$arr[“AppServerSessionID”] = new xmlrpcval($data->AppServerSessionID, “string”);
$res->addStruct($arr);
return $res;
}
static function FromArray($data)
{
$items = array();
for ($i = 0; $i < sizeof($data); $i++) {
$items[$i] = TRoUserAuthenticationResult::ToXmlRpcVal($data[$i]);
}
$res = new xmlrpcval();
$res->addArray($items);;
return $res;
}
static function ToArray($data)
{
$items = array();
for ($i = 0; $i < $data->arraysize(); $i++) $items[$i] = TRoUserAuthenticationResult::FromXmlRpcVal($data->arraymem($i));
return $items;
}
}

I was wondering maybe this was a default procedure of CodeGen.

Thanks

Hi

I have tested your RODL, but can’t reproduce this bug. But quick review shows that the same bug was found in 2008 year. Which version of codegen you use? Anyway you need to update it

Hi,

Upon looking at the plugins loaded in the service builder, I manage to found that i’m using RemObjects SDK PHP Interface Generator version 1.0

Please tell me how to update the module.

Thanks and more power

Hi.

Need get new version of RemObjects SDK with new Service Builder. You can test it using trial (Data Abstract for Delphi which includes RemObjects SDK) from http://www.remobjects.com/trials.aspx .

Hi,

First thank you for your immediate response,

Can you tell me if their are issues with regards to different versions of two service builders? I tried using Service Builder version 6 and import RODL from version 5, I noticed that datatypes that are “strings” when generated in version 6 it becomes “ansistring” and I encountered error upon compiling and calling myservice “Invalid sting length” but everything is fine on version 5.

Thanks for all

Hi,

There are 3 types of string:
AnsiString
WideString
UTFString

i’m not quite understand where is type string was changed? The code generate only type string. The “Invalid sting length” exception thrown in case reading string with wrong type.

I tried to reproduce this error but unfortunately I was unable to. Can you send testcase and RODL please?