Dear all, I've committed a first implementation of the RESTful API as described on http://dev.xwiki.org/xwiki/bin/view/Design/RestfulAPI Not all the URIs are working but pages and translations are. You can: * GET / * GET /spaces * GET /spaces/{spaceId}/pages * GET|PUT /spaces/{spaceId}/pages/{pageId} * GET|PUT /spaces/{spaceId}/pages/{pageId}/translations/{translationId} PUT will create/modify the corresponding page. You can use curl to interoperate with the API. Some examples: * curl -u Admin:admin -X PUT -d "Hello world" -H "Content-Type: text/plain" http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome Will set the content of Main.WebHome to "Hello world" * curl -u Admin:admin -X PUT -d @text.txt -H "Content-Type: text/plain" http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome Will set the Main.WebHome content to whatever is writen in the text.txt file. * curl -u Admin:admin -X PUT -d @page.xml -H "Content-Type: application/xml" http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome Will set the Main.WebHome attributes to whatever is written in the page.xml. The xml file must conform to the structure described in the design page. This allows to change the content, the title and to reparent the page. * curl -u Admin:admin -X PUT -d @text.txt -H "Content-Type: text/plain" http://localhost:8080/xwiki/rest/spaces/Not/pages/Existing Will create the Not.Existing page and set its content to whatever is writen in the text.txt file. Currently the implementation is in the sandbox and is available for public review (http://svn.xwiki.org/svnroot/xwiki/sandbox/xwiki-core-rest/). It uses the XStream library (http://xstream.codehaus.org) for XML serialization/deserialization of data types. Very handy. Comments are welcome. -Fabio
Sounds like a good start, well done Fabio. Do we have a URI that exposes all available services yet? Thanks -Vincent On Dec 31, 2008, at 12:09 AM, Fabio Mancinelli wrote:
Dear all,
I've committed a first implementation of the RESTful API as described on http://dev.xwiki.org/xwiki/bin/view/Design/RestfulAPI
Not all the URIs are working but pages and translations are.
You can:
* GET / * GET /spaces * GET /spaces/{spaceId}/pages * GET|PUT /spaces/{spaceId}/pages/{pageId} * GET|PUT /spaces/{spaceId}/pages/{pageId}/translations/ {translationId}
PUT will create/modify the corresponding page.
You can use curl to interoperate with the API. Some examples:
* curl -u Admin:admin -X PUT -d "Hello world" -H "Content-Type: text/plain" http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome Will set the content of Main.WebHome to "Hello world"
* curl -u Admin:admin -X PUT -d @text.txt -H "Content-Type: text/ plain" http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome Will set the Main.WebHome content to whatever is writen in the text.txt file.
* curl -u Admin:admin -X PUT -d @page.xml -H "Content-Type: application/xml" http://localhost:8080/xwiki/rest/spaces/Main/pages/WebHome Will set the Main.WebHome attributes to whatever is written in the page.xml. The xml file must conform to the structure described in the design page. This allows to change the content, the title and to reparent the page.
* curl -u Admin:admin -X PUT -d @text.txt -H "Content-Type: text/ plain" http://localhost:8080/xwiki/rest/spaces/Not/pages/Existing Will create the Not.Existing page and set its content to whatever is writen in the text.txt file.
Currently the implementation is in the sandbox and is available for public review (http://svn.xwiki.org/svnroot/xwiki/sandbox/xwiki-core-rest/). It uses the XStream library (http://xstream.codehaus.org) for XML serialization/deserialization of data types. Very handy.
Comments are welcome.
-Fabio
Vincent Massol wrote:
Sounds like a good start, well done Fabio.
Do we have a URI that exposes all available services yet?
Rooted at / there is a "service document" that contains all the entry points. Currently it looks like this: <?xml version="1.0" encoding="UTF-8"?> <xwiki> <link rel="http://www.xwiki.org/rel/spaces" href="http://localhost:8080/xwiki/rest/spaces"/> </xwiki> It can and will be extended as more services will be implemented and become available (e.g., watchlist, tags, etc.) -Fabio
Wouldn't this be easily written in WSDL or WADL? I believe it would be useful. For WSDL, It'd be WSDL 2, not WSDL 1 (which almost could only do soap). paul Le 31-déc.-08 à 09:59, Fabio Mancinelli a écrit :
Vincent Massol wrote:
Sounds like a good start, well done Fabio.
Do we have a URI that exposes all available services yet?
Rooted at / there is a "service document" that contains all the entry points. Currently it looks like this:
<?xml version="1.0" encoding="UTF-8"?> <xwiki> <link rel="http://www.xwiki.org/rel/spaces" href="http://localhost:8080/xwiki/rest/spaces"/> </xwiki>
It can and will be extended as more services will be implemented and become available (e.g., watchlist, tags, etc.)
Paul Libbrecht wrote:
Wouldn't this be easily written in WSDL or WADL? I believe it would be useful.
For WSDL, It'd be WSDL 2, not WSDL 1 (which almost could only do soap).
There has been a lot of criticism about WADL (e.g, [1]) as a way of putting RPC-ishness into something that should not be RPC-ish. So I would prefer to follow the "hypermedia way" as ATOM does. Nevertheless, WADL is useful for people who want to auto generate their strongly-coupled clients so it is indeed an option to expose. I still have to dig into it. RESTlet seems to support it out of the box. We can expose it somewhere like /wadl and link this URI in the previous cited "service document" -Fabio [1] http://bitworking.org/news/193/Do-we-need-WADL
Paul Libbrecht wrote:
Wouldn't this be easily written in WSDL or WADL? I believe it would be useful.
It was easy so I added it. Here it is how it works: 1) curl http://localhost:8080/xwiki/rest/ Will get the standard service document. A link is added to "/" with rel="wadl" and type="application/vnd.sun.wadl+xml" to describe the fact that at this URI a WADL description is also available. 2) curl -H "Accept: application/vnd.sun.wadl+xml" http://localhost:8080/xwiki/rest/ Will get a WADL description of the whole application. 3) curl -X OPTIONS http://localhost:8080/xwiki/rest/ Equivalent to 2. RESTlet automatically gives WADL description of resources when an OPTION request is sent. Doing this at the application root will describe the whole application. The same can be done on other URIs in order to have a WADL description of the specific target resource. -Fabio
participants (3)
-
Fabio Mancinelli -
Paul Libbrecht -
Vincent Massol