Xebra Create XML-RPC Webapp: Difference between revisions
Jump to navigation
Jump to search
New page: Category:Xebra * Create a new file ''demo.xrpc'' in the webapp directory . On translation, this will generate a xml-rpc servlet class. <xml> <xrpc:api class="MY_XMLRPC_API" namespace... |
No edit summary |
||
| Line 1: | Line 1: | ||
[[Category:Xebra]] | [[Category:Xebra]] | ||
* Create a new file ''demo.xrpc'' in the webapp directory . On translation, this will generate a xml-rpc servlet class. | * Create a new file ''demo.xrpc'' in the webapp directory. On translation, this will generate a xml-rpc servlet class. | ||
<xml> | <xml> | ||
| Line 16: | Line 16: | ||
MY_XMLRPC_API | MY_XMLRPC_API | ||
inherit | |||
XWA_XRPC_API | |||
feature -- Basic operations | feature -- Basic operations | ||
| Line 29: | Line 31: | ||
sum (i, j: NATURAL_16): INTEGER | sum (i, j: NATURAL_16): INTEGER | ||
-- XML-RPC using Eiffel types. | -- XML-RPC using Eiffel types. | ||
do | do | ||
Result := (i + j).as_integer_32 | Result := (i + j).as_integer_32 | ||
| Line 37: | Line 37: | ||
</e> | </e> | ||
* Run the server and browse to http://localhost:55000/yourwebapp/demo.xrpc. | * Run the server and browse to http://localhost:55000/yourwebapp/demo.xrpc. After the webapp has been translated, compiled and run you should see a page saying ''invalid method''. That is because you tried to make an xml-rpc call with a GET request. Only POST is allowed, though. | ||
* To make an actual xml-rpc call you can use python. Run: | |||
<c> | |||
>>> import xmlrpclib | |||
>>> s=xmlrpclib.ServerProxy("http://localhost:55000/yourwebapp/demo.xrpc") | |||
>>> s.demo.sum(4,5) | |||
>>> s.math.hello("Gerhard") | |||
</c> | |||
Revision as of 21:37, 1 July 2009
- Create a new file demo.xrpc in the webapp directory. On translation, this will generate a xml-rpc servlet class.
<xrpc:api class="MY_XMLRPC_API" namespace="demo"> <xrpc:method name="sum" /> <xrpc:method name="hello" /> </xrpc:api>
- Now go into estudio and create a new class MY_XMLRPC_API:
class MY_XMLRPC_API inherit XWA_XRPC_API feature -- Basic operations hello (a_name: STRING): STRING require a_name_attached: attached a_name not_a_name_is_empty: not a_name.is_empty do Result := "Hello there " + a_name.string end sum (i, j: NATURAL_16): INTEGER -- XML-RPC using Eiffel types. do Result := (i + j).as_integer_32 end end
- Run the server and browse to http://localhost:55000/yourwebapp/demo.xrpc. After the webapp has been translated, compiled and run you should see a page saying invalid method. That is because you tried to make an xml-rpc call with a GET request. Only POST is allowed, though.
- To make an actual xml-rpc call you can use python. Run:
>>> import xmlrpclib >>> s=xmlrpclib.ServerProxy("http://localhost:55000/yourwebapp/demo.xrpc") >>> s.demo.sum(4,5) >>> s.math.hello("Gerhard")