On the topic of XML-RPC, input needed... (Long and Related to: XML-RPC Stack almost there)

Mark Brownell gizmotron at earthlink.net
Sat Sep 6 21:52:00 EDT 2003


On Saturday, September 6, 2003, at 05:14  PM, Andre Garzia wrote:

Andre,

Here is my contribution. It comes in the form of
the simplicity of using a pull-parser.

Kindest regards,
Mark Brownell


 From lower down:
> * our only viable alternative is SOAP and SOAP is simple an annoying, 
> strange, complex piece of burocracy. But it's already implemented in 
> Rev.

 From higher up:
> <?xml version="1.0"?>
> <methodCall>
>   <methodName>examples.getStateName</methodName>
>    <params>
>       <param>
>          <value><i4>23</i4></value>
>       </param>
>    </params>
> </methodCall>

> --=========================

> <?xml version="1.0"?>
> <methodResponse>
> 	<params>
> 		<param>
> 			<value>Minnesota</value>
> 		</param>
> 	</params>
> </methodResponse>

> --=========================

> <?xml version="1.0"?>
> <methodCall>
>  <methodName>MainStack.addToField</methodName>
>    <params>
>       <param>
>          <value><string>All your remote methods are belong to 
> us</string></value>
>       </param>
>     </params>
> </methodCall>
>
> This call would be sent to function call "addToField" of your 
> mainstack. The first part before the dot could be the stack, the 
> second part the method. we could go further to use even <name of the 
> stack>.<name of the card>.<function to call> structure (Ex: 
> MainStack.report.addToReport), if the stack is not present in memory, 
> it would search for a file with the same name, load it and send the 
> function call to it... the return would be echoed to remote client. 
> Since rev function can return only one parameter, we could create help 
> functions to assemble everything we want to return in one huge string 
> (Thats what base64 is for) and decode it on client.

[snip]

>
> I dream some day to be able to write:
>
> send "Example.GetStateName 41" to URL http://betty.userland.com/RPC2
--=====================================================

OK, my two cents,

This looks just like MTML:
> <name of the stack>.<name of the card>.<function to call>

...even though I understand it is descriptive of the parts.

> <methodCall>
>   <methodName>examples.getStateName</methodName>
>    <params>
>       <param>
>         <value><string>Andre does the hat trick.</string></value>

If you don't have to comply with XML-RPC you could use an MTML 
pull-parser with MTML and if you want to you can even send multi-lined 
source code for sending process with data.

-- Although your data can be well-formed XML-RPC it would be parsed as 
MTML.
-- As MTML you could drop multi-lined source code within a <value> tag 
set.
-- You could also pass encrypted data inside the <value> tag set.

-- send your message or array of calls to create a list, 
-- & put your MTML or XML-RPC structured message into tPullThis

put PNLPgetElement("<methodCall>", "</methodCall>", tPullThis) into 
tMethodCall
   or
put PNLPgetElement("<methodResponse>", "</methodResponse>", tPullThis) 
into tMethodResponse

put PNLPgetElement("<methodName>", "</methodName>", tMethodCall) into 
tMethodName
-- tMethodName  = "MainStack.addToField"

put getPNLPelements("<param>", "</param>", tMethodCall) into 
theParamArray

-- this function creates an array of all instances of "<param>", 
"</param>"
-- you could extract values from the param array with:

put PNLPgetElement("<value>", "<value>", theParamArray[1]) into tValue
-- tValue  = "<string>Andre does the hat trick.</string>"

function getPNLPelements tStartTag, tEndTag, StringToSearch
   put empty into tArray
   put 0 into tStart1
   put 0 into tStart2
   put 1 into tElementNum
   put the number of chars in tStartTag into dChars
   repeat
     put offset(tStartTag,StringToSearch,tStart1) into tNum1
     put (tNum1 + tStart1) into tStart1
     if tNum1 < 1 then exit repeat
     put offset(tEndTag,StringToSearch,tStart2) into tNum2
     put (tNum2 + tStart2) into tStart2
     if tNum2 < 1 then exit repeat
     --if tNum2 < tNum1 then exit repeat
     put char (tStart1 + dChars) to (tStart2 - 1) of StringToSearch into 
zapped
     put zapped into tArray[tElementNum]
     add 1 to tElementNum
   end repeat
   return tArray
end getPNLPelements


function PNLPgetElement tStTag, tEdTag, stngToSch
   put empty into zapped
   put the number of chars in tStTag into dChars
   put offset(tStTag,stngToSch) into tNum1
   put offset(tEdTag,stngToSch) into tNum2
   if tNum1 < 1 then
     return "error"
     exit PNLPgetElement
   end if
   if tNum2 < 1 then
     return "error"
     exit PNLPgetElement
   end if
   put char (tNum1 + dChars) to (tNum2 - 1) of stngToSch into zapped
   return zapped
end PNLPgetElement

-- Example: put PNLPgetAttribute("name", tZap) into theAttribute
function PNLPgetAttribute tAttribute, strngToSearch
   put empty into zapA
   put quote into Qx
   put tAttribute & "=" & Qx into tAttributeX
   put the number of chars in tAttributeX into dChars
   put offset(tAttributeX,strngToSearch) into tNum1
   if tNum1 < 1 then
     return "error"
     exit PNLPgetAttribute
   end if
   put tNum1 + 1 into tNum2
   put offset(Qx,strngToSearch,tNum2) into tNum3
   put offset("=",strngToSearch,tNum2) into tNum4
   if tNum3 < 1 then
     return "error"
     exit PNLPgetAttribute
   end if
   if tNum4 < tNum3 then
     return "error"
     exit PNLPgetAttribute
   end if
   put char (tNum2 + 1) to (tNum3 - 1) of stngToSch into zapA
   return zapA
end PNLPgetAttribute




More information about the use-livecode mailing list