Re:
Martin Klang <[email protected]> Thu, 5 Aug 2004 00:50:24 +0100
| Newsgroups | gmane.text.xml.o-xml |
|---|---|
| Message-ID | <[email protected]> |
On 4 Aug 2004, at 21:01, Rashmi Shashikant Jali wrote:
> We want to use as much xml as possible so that api
> test cases are self documenting.
> So for this we have api names and parameters
> encoded in XML.
Seems a good start. It should make it easy to generate things like
documentation.
And you could generate HTML forms that allow you to fill in the
parameter values. The forms can post to o:XML programs (in a Servlet
environment) that create and send XML-RPC requests and return the
result.
Also possible to generate simple o:XML programs from the specification
- they wouldn't do much apart from creating the request based on input
params and return the result. Maybe not quite what you want. Are you
wanting to test the client code or the server?
For server testing you might also want to check out
http://hatatap.pingdynasty.com which has a really neat XML script
format. Hatatap scripts are declarative, but they can include o:XML
code for logic and conditionals. Actually any o:XML can be included.
I've played around a bit with writing an XML-RPC client that calls the
freshmeat API - see
http://freshmeat.net/articles/view/1048/
Here's a very simple example that fetches a list of licenses:
<?xml version='1.0'?>
<o:program xmlns:o="http://www.o-xml.org/lang/"
xmlns:io="http://www.o-xml.org/lib/io/"
xmlns:net="http://www.o-xml.org/lib/net/">
<o:param name="url" select="'http://freshmeat.net/xmlrpc/'"/>
<o:import href="lib/net/URL.oml"/>
<o:variable name="request">
<o:document>
<methodCall>
<methodName>fetch_available_licenses</methodName>
<params/>
</methodCall>
</o:document>
</o:variable>
<o:set url="net:URL($url)"/>
<o:set response="$url.post($request)"/><!-- send the request -->
<o:log msg="got: {$response.code()} {$response.contentType()}."/>
<o:set content="$response.content()"/><!-- do stuff with the response
-->
<o:set body="$response.parse()"/>
<o:eval select="$body/methodResponse"/>
</o:program>
I also started work on creating generic XML-RPC types for o:Lib - it
should be included with the next release.
Another nice use of o:XML is to write XML-RPC server code. At the
moment you have to use the Java and Servlet extensions together with
the io libs to parse the request input stream. I plan to make it easier
to get the input XML through a parameter but not quite sure how yet.
Any suggestions?
Alternatives I've thought about that would be fairly portable:
<o:program>
<o:param name="io:inputstream"/> <!-- use 'magic' parameter name -->
or:
<o:param name="foobar" type="io:Stream"/><!-- attach input stream to
any/first parameter of Stream type -->
The actual stream would be depending on the execution context, ie
stdin/stdout for commandline execution or the request
input/outputstream for servlet execution. If the context can't provide
a stream, the program fails.
sorry for waffling on a bit... hope the example is useful at least!
regards,
/m