Re: return an array
Didier M.J.C. Gehéniau <[email protected]> Fri, 5 Dec 2008 13:11:00 +0100
| Newsgroups | gmane.comp.php.xml-rpc |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format. --===============0066020457== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0035_01C956DA.EB237AC0" Content-Language: nl This is a multipart message in MIME format. ------=_NextPart_000_0035_01C956DA.EB237AC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks, =20 That was one problem and de second one i found out: my array was = =93lastname=94, =93geheniau=94 and not =93lastname =3D> =93geheniau=94 ;) =20 It=92s working now =20 =20 =20 On Fri, Dec 5, 2008 at 12:27 AM, <[email protected]> wrote: Hi all, I have the following simple code: <? include ("lib/xmlrpc.inc"); include ("lib/xmlrpcs.inc"); include ("lib/xmlrpc_wrappers.inc"); $userInfo =3D new xmlrpcval ( array( "dgeheniau", new xmlrpcval ( array( "lastname", new xmlrpcval ("Geheniau", "string"), "firstname", new xmlrpcval ("Didier", "string"), "email", new xmlrpcval = ("[email protected]", "string") ), "struct") ), "struct"); $getUserInfo_sig =3D array(array($xmlrpcStruct, $xmlrpcString)); $getUserInfo_doc =3D "This function will return all know user info!"; function getUserInfo ($userName){ Here $userName will not be a string but an object. You will need to extract the 1st param received from this object, and = its then its string value. Btw, if you are doing all the encoding/decoding from php values to = xmlrpc values by hand you do not need to include xmlrpc_wrappers.inc - that lib = is used when you want to automatically turn plain php functions (ie = functions that do not deal with xmlrpcvals) into server methods. Bye Gaetano global $userInfo; return new xmlrpcresp(new xmlrpcval($userInfo->structmem("$userName"), "struct")); } #$o=3Dnew xmlrpc_server_methods_container; $a=3Darray( "user.getUserInfo" =3D> array( "function" =3D> "getUserInfo", "signature" =3D> $getUserInfo_sig, "docstring" =3D> $getUserInfo_doc ) ); $s=3Dnew xmlrpc_server($a, false); $s->setdebug(3); $s->compress_response =3D true; $s->service(); ?> In the client I get: +++PROCESSING ERRORS AND WARNINGS+++ Object of class xmlrpcmsg could not be converted to string Undefined index: +++END+++ What am I doing wrong? Regards, Didier =20 ------=_NextPart_000_0035_01C956DA.EB237AC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Diso-8859-1"> <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" = xmlns=3D"http://www.w3.org/TR/REC-html40"> <head> <meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)"> <style> <!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:"\@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman","serif";} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;} span.EmailStyle17 {mso-style-type:personal-reply; font-family:"Calibri","sans-serif"; color:#1F497D;} .MsoChpDefault {mso-style-type:export-only;} @page Section1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 70.85pt 70.85pt;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body lang=3DNL link=3Dblue vlink=3Dpurple> <div class=3DSection1> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'>Thanks,<o:p></o:p></span></p> <p class=3DMsoNormal><span = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <p class=3DMsoNormal><span lang=3DEN-US = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'>That was one problem and de second one i found out: my = array was “lastname”, “geheniau” and not “lastname = =3D> “geheniau” ;)<o:p></o:p></span></p> <p class=3DMsoNormal><span lang=3DEN-US = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <p class=3DMsoNormal><span lang=3DEN-US = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'>It’s working now<o:p></o:p></span></p> <p class=3DMsoNormal><span lang=3DEN-US = style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif"; color:#1F497D'><o:p> </o:p></span></p> <div style=3D'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm = 0cm 4.0pt'> <p class=3DMsoNormal><span lang=3DEN-US><o:p> </o:p></span></p> <p class=3DMsoNormal style=3D'margin-bottom:12.0pt'><span = lang=3DEN-US><o:p> </o:p></span></p> <div> <p class=3DMsoNormal>On Fri, Dec 5, 2008 at 12:27 AM, <<a href=3D"mailto:[email protected]">[email protected]</a>>= wrote:<o:p></o:p></p> <p class=3DMsoNormal>Hi all,<br> <br> <br> I have the following simple code:<br> <br> <?<br> include ("lib/xmlrpc.inc");<br> include ("lib/xmlrpcs.inc");<br> include ("lib/xmlrpc_wrappers.inc");<br> <br> $userInfo =3D new xmlrpcval ( array(<br> = "dgeheniau", new xmlrpcval (<br> = array(<br> = "lastname", new xmlrpcval ("Geheniau",<br> "string"),<br> = "firstname", new xmlrpcval ("Didier",<br> "string"),<br> = "email", new xmlrpcval = ("<a href=3D"mailto:[email protected]">[email protected]</a>",<br> "string")<br> = ),<br> = "struct")<br> ), "struct");<br> <br> $getUserInfo_sig =3D array(array($xmlrpcStruct, $xmlrpcString));<br> $getUserInfo_doc =3D "This function will return all know user = info!";<br> <br> function getUserInfo ($userName){<o:p></o:p></p> <div> <p class=3DMsoNormal style=3D'margin-bottom:12.0pt'><br> Here $userName will not be a string but an object.<br> You will need to extract the 1st param received from this object, and = its then its string value.<br> Btw, if you are doing all the encoding/decoding from php values to = xmlrpc values by hand you do not need to include xmlrpc_wrappers.inc - that lib = is used when you want to automatically turn plain php functions (ie functions = that do not deal with xmlrpcvals) into server methods.<br> <br> Bye<br> Gaetano<o:p></o:p></p> </div> <blockquote style=3D'border:none;border-left:solid #CCCCCC = 1.0pt;padding:0cm 0cm 0cm 6.0pt; margin-left:4.8pt;margin-right:0cm'> <p class=3DMsoNormal><br> global $userInfo;<br> return new xmlrpcresp(new<br> xmlrpcval($userInfo->structmem("$userName"), = "struct"));<br> <br> }<br> <br> #$o=3Dnew xmlrpc_server_methods_container;<br> $a=3Darray(<br> "user.getUserInfo" =3D> = array(<br> = "function" =3D> "getUserInfo",<br> = "signature" =3D> $getUserInfo_sig,<br> = "docstring" =3D> $getUserInfo_doc<br> )<br> );<br> <br> $s=3Dnew xmlrpc_server($a, false);<br> $s->setdebug(3);<br> $s->compress_response =3D true;<br> $s->service();<br> ?><br> <br> In the client I get:<br> <br> +++PROCESSING ERRORS AND WARNINGS+++<br> Object of class xmlrpcmsg could not be converted to string<br> Undefined index:<br> +++END+++<br> <br> What am I doing wrong?<br> <br> Regards,<br> <br> Didier<o:p></o:p></p> </blockquote> </div> <p class=3DMsoNormal><o:p> </o:p></p> </div> </div> </body> </html> ------=_NextPart_000_0035_01C956DA.EB237AC0-- --===============0066020457== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ phpxmlrpc mailing list [email protected] http://lists.usefulinc.com/cgi-bin/mailman/listinfo/phpxmlrpc --===============0066020457==--