Re: Difference between Trim($HTTP_POST_VARS["sh"]) and scalarval()

"erasmus_joshi" <[email protected]>
Newsgroups gmane.text.xml.rpc.specification
Message-ID <[email protected]>
Hello Gaetano,

thanks for your answer to my confused question. It already helped a
little bit. I want to try to explain it a better this time:

There is one code in php that is working. This code is using
$HTTP_POST_VARS["var"] to pass parameters. My work is to get this code
working in nearly the same way but to pass the parameters in another way. 

The first time I use the method "rpc_call" it returns an scalarval()
that consists of 10 digits (yes, it is larger than an normal Int) and
I save it like $sh = $v->scalarval();

This works well. 

In the next step I want to logout. For this method I have to pass the
variable $sh to the method like:
xmlrpcval(Trim($HTTP_POST_VARS["sh"]), $xmlrpcInt)); 
The developer of the existing and well working code used for this a
form to post the vars and then used it in the code. 

The way I have to do it is ... without this form - posting because it
is part of an workflow: So I wanted to use the code like:
xmlrpcval(Trim($v->scalarval()), $xmlrpcInt)); 
For me this meant nearly the same like the code above but I use the
variable $v->scalarval() direct and not indirect via sending the form
with the hidden field for sh and use the $HTTP_POST_VARS["sh"]. 

Like I told.. for me it was the same because the method got a value
that with the size of 10 characters. 
The code that makes the difference is in the function createPayload().
When it puzzles the xml-tags together the strlen of
strlen($p->serialize() returns 43 when I pass the params via
$v->scalarval() and 37 if I pass the params via $HTTP_POST_VARS["sh"]).

Printing out the result of $p->serialize() via echo ... outputs in
both ways something that has contains of 10 digits. 

The point I don't get is what kind of control-codes like \n\f .. can
be hidden in this code, how to make it visible and more over .. how to
get the same strlen for both values?

In this case I need the strlen of 37 because otherwise the server
takes the http-header and adds 6 empty spaces to the parameter on the
server side. This ends up in something like "1234567897      " in this
is definitly (not even for me *g*) a number. So the server sends the
response that the parameter is wrong because there should be an int as
the first parameter but there is an string. 

And that the problem. 
So the question is ... what kind of magic is this (IMHO - really good)
xmlrpc thing doing in serialize that enlarges the string unneccessary.
Could it be the encoding and what can I do to make this work. 

Thanks for reading and hopefully now it gets more clear what's the
problem between me, xmlrpc and the rest. 

Thx in advance, Sascha  


		}
--- In [email protected], "Gaetano Giunta" <giunta.gaetano@s...>
wrote:
>
> I might be missing the point, since the description is somewhat
confused, but...
> 
> $p = new xmlrpcval(Trim($HTTP_POST_VARS["sh"]), $xmlrpcInt)
> 
> will create an xmlrpcval of type int.
> This means than when calling $p->serialize(), an <int> tag will be used.
> The library does NOT coerce the php value passed to it to INT type,
but it leaves it untouched.
> This means that if Trim($HTTP_POST_VARS["sh"] is not an integer, it
will be printed as it is anyway.
> 
> In the latest release of the library, only avalibale in CVS (but
soon it will be posted as 2.0RC3), this has been cahnged:
> $p->scalarval() will still return the original value you pass to it
> $p->serialize() will coerce the value to an ineteger before creating
the xml (ie '0000' will return <int>0</int>, and 'hello' will return 0
as well).
> 
> You should also take care about your code using leading zeroes...
> 
> Hope it helps
> Gaetano
> 
> > -----Original Message-----
> > From: [email protected] 
> > [mailto:[email protected]]On Behalf
> > Of erasmus_joshi
> > Sent: Tuesday, January 10, 2006 1:26 PM
> > To: [email protected]
> > Subject: [xml-rpc] Difference between Trim($HTTP_POST_VARS["sh"]) and
> > scalarval()
> > 
> > 
> > Hello, 
> > 
> > I have a - maybe - really stupid question but I am new to this topic
> > and don't find a way to solve it myself.
> > 
> > There is an existing xmlrpc client that works perfectly. I want to
> > adopt this client to Typo3 and the xmlrpc communications also works
> > really good. But I have on big problem with the following thing: 
> > 
> > The communication is step by step. First I have to connect to the
> > server. This works perfect. This Server respones with an SessionID
> > with a length of 10 numbers. And that is the point. I have to use this
> > number as parameter in all methods. 
> > 
> > The new and the old code are only unequal in the type calling the
> > methods. The working version is reading the variable by
> > $HTTP_POST_VARS["sh"]. I use the result of the response scalarval..
> > 
> > ----snip----
> > if ($v = rpc_call($c, $f)) {
> > 			echo "Login () returns: 
> > ",$v->scalarval(),"<br>";
> > 			$sh = $v->scalarval();
> > 
> > 	$f= new xmlrpcmsg('sdb.Logout');
> > 		$f->addParam(new 
> > xmlrpcval(Trim($HTTP_POST_VARS["sh"]), $xmlrpcInt));
> > 
> > --- snap ----
> > 
> > The point I don't get is that in the method createPayload the 
> > 		->echo
> > "Payload -> param -> serialize size = " . strlen($p->serialize()).
> > "<br>";<--
> > serialize value send as parameter via $HTTP_POST_VARS has a strlen
> > that is 6 shorter than the parameter send by scalarval. 
> > 
> > Could this be a problem with encoding or has someone a idea what I am
> > doing wrong?
> > 
> > Sorry for the bad description.. but somehow I am really confused at
> > the moment and hope someone understood what I wanted to tell. 
> > 
> > Thx in advance, Sascha
> > 	
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> >
>







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/xml-rpc/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.