Discussion:
[phpxmlrpc] Read the XML File
kutty S.B.
2006-09-14 14:48:58 UTC
Permalink
Hi all,

I connect to Server and got the response from server.

how i write the result into the xml files.

It is Possible??

Thanks in advance





---------------------------------
Find out what India is talking about on - Yahoo! Answers India
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.usefulinc.com/pipermail/phpxmlrpc/attachments/20060914/7abed0c9/attachment.htm
Gaetano Giunta
2006-09-14 17:01:21 UTC
Permalink
I am not really sure I undertand what you are asking...

If what you need is to save the responses received from the server as xml, =
you have two options:

1- use the serialize() method on the response object.

$resp =3D $client->send($msg);
if (!$resp->faultCode())
$data_to_be_saved =3D $resp->serialize();
etc...

Note that this will not be 100% accurate, since the xml generated by the re=
sponse object can be different from the xml received, especially if there i=
s some character set conversion involved, or such (eg. if you receive an em=
pty string tag as <string/>, serialize() will output <string></string>), or=
if the server sent back as response something invalid (in which case the x=
ml generated client side using serialize() wil correspond to the error resp=
onse generated internally by the lib)


2 - set the client object to return the raw xml received instead of the dec=
oded objects:

$client =3D new xmlrpc_client($whatever);
$client->return_type =3D 'xml'
$resp =3D $client->send($msg);
if (!$resp->faultCode())
$data_to_be_saved =3D $resp->value();
etc...

Note that using this method the xml response response will not be parsed at=
all by the library, only the http commuincation will be checked. This mean=
s that xmlrpc responses sent by the server that would have generated an err=
or response on the client (eg. malformed xml, responses that have faultcode=
/faultmsg set, etc...) now.

Hope this helps
Gaetano

-----Original Message-----
From: phpxmlrpc-***@lists.usefulinc.com [mailto:phpxmlrpc-***@lis=
ts.usefulinc.com]On Behalf Of kutty S.B.
Sent: Thursday, September 14, 2006 11:49 AM
To: ***@lists.usefulinc.com
Subject: [phpxmlrpc] Read the XML File


Hi all,

I connect to Server and got the response from server.

how i write the result into the xml files.

It is Possible??

Thanks in advance





---------------------------------------------------------------------------=
---
Find out what India is talking about on - Yahoo! Answers India =

Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Ge=
t it NOW
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.usefulinc.com/pipermail/phpxmlrpc/attachments/20060914/d5=
c91797/attachment.htm
Gaetano Giunta
2006-09-15 13:33:33 UTC
Permalink
Sorry, but I think you should really start by reading the manual (it is ver=
y complete and informative) and take a look at all the code examples that a=
re part of the download.

As a php developer, the php error message you receive would tell me that th=
e $data_to_be_saved variable is not what you expect it to be (namely an xml=
rpcval object), so, in order to debug the code I would just add this line:
var_dump($data_to_be_saved);
to find out what is going on.

To spare you the trouble of doing it, I can tell you that $resp->serialize(=
) returns a string (the xml representation of the response), while $resp->v=
alue() returns the value received as xmlrpcval object.

Bye
Gaetano
-----Original Message-----
From: kutty S.B. [mailto:***@yahoo.co.in]
Sent: Friday, September 15, 2006 6:56 AM
To: Gaetano Giunta
Subject: RE: [phpxmlrpc] Read the XML File


hi

Thank u very much.

$data_to_be_saved =3D $resp->serialize();

It is show the full result.

But I try to get some particular value like

$struct =3D $data_to_be_saved->value();
$sumval =3D $struct->structmem('sum');
$sum =3D $sumval->scalarval();

I got following error

Fatal error: Call to a member function on a non-object in "$struct =3D=
$data_to_be_saved->value()";

How i receive the particular value.

Thanks in advance.



Gaetano Giunta <***@sea-aeroportimilano.it> wrote:
I am not really sure I undertand what you are asking...

If what you need is to save the responses received from the server as x=
ml, you have two options:

1- use the serialize() method on the response object.

$resp =3D $client->send($msg);
if (!$resp->faultCode())
$data_to_be_saved =3D $resp->serialize();
etc...

Note that this will not be 100% accurate, since the xml generated by th=
e response object can be different from the xml received, especially if the=
re is some character set conversion involved, or such (eg. if you receive a=
n empty string tag as <string/>, serialize() will output <string></string>)=
, or if the server sent back as response something invalid (in which case t=
he xml generated client side using serialize() wil correspond to the error =
response generated internally by the lib)


2 - set the client object to return the raw xml received instead of the=
decoded objects:

$client =3D new xmlrpc_client($whatever);
$client->return_type =3D 'xml'
$resp =3D $client->send($msg);
if (!$resp->faultCode())
$data_to_be_saved =3D $resp->value();
etc...

Note that using this method the xml response response will not be parse=
d at all by the library, only the http commuincation will be checked. This =
means that xmlrpc responses sent by the server that would have generated an=
error response on the client (eg. malformed xml, responses that have fault=
code/faultmsg set, etc...) now.

Hope this helps
Gaetano

-----Original Message-----
From: phpxmlrpc-***@lists.usefulinc.com [mailto:phpxmlrpc-bounces=
@lists.usefulinc.com]On Behalf Of kutty S.B.
Sent: Thursday, September 14, 2006 11:49 AM
To: ***@lists.usefulinc.com
Subject: [phpxmlrpc] Read the XML File


Hi all,

I connect to Server and got the response from server.

how i write the result into the xml files.

It is Possible??

Thanks in advance




--------------------------------------------------------------------------
Find out what India is talking about on - Yahoo! Answers India =

Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8=
. Get it NOW
_______________________________________________
phpxmlrpc mailing list
***@lists.usefulinc.com
http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc





---------------------------------------------------------------------------=
---
Find out what India is talking about on - Yahoo! Answers India =

Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Ge=
t it NOW
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.usefulinc.com/pipermail/phpxmlrpc/attachments/20060915/30=
8bec79/attachment-0001.htm

Continue reading on narkive:
Loading...