> Since I don't want to make everything "updating", because I dont want to
> introduce unnecessary synchronization, I'd like to just call the native
> functions through the forwarding mechanism passing ahead the POST content of
> the request and exploiting the nice declarative way of routing with
> parametric path annotations. […]
I guess I should spend more time on understanding your use case, but
due to my lazyness, I’m just asking why you don’t directly call the
functions instead of using redirects? À la…
OLD:
(: do all SOAP related work here :)
<rest:forward>{
"test/impl"
}</rest:forward>
NEW:
(: do all SOAP related work here :)
soapskel:impl($postbody)
If it makes sense.. Do you have an example that demonstrates why this
isn’t possible?
> According to the optionality of the postbody parameter it works when I call
> a RESTXQ function directly. It also works when forwarding if the orignal
> HTTP request doesn't have any postbody. But when the postbody is there in
> the original request, the subsequent function (where I forward to) yields
> the error.
I just tried your example with the following curl call. As expected,
it returns nothing, but it doesn’t raise an error either:
> curl -i -XPOST -d"<a/>" "localhost:8984/test"
HTTP/1.1 200 OK
Content-Type: application/xml; charset=UTF-8
Content-Length: 0
Server: Jetty(8.1.11.v20130520)
Do you see what I did wrong?
Christian
> Of course I'm also ready to accept architectural suggestions if this can
> satisfy my needs ;-)
>
> Here is a code snippet that should reproduce the error on 7.7.2. Both the
> plain version plus the one that uses the session trick.
> Hope this helps.
> Regards.
>
> module namespace soapskel = 'urn:myns';
> import module namespace session = "http://basex.org/modules/session";
> declare
> %rest:path("test")
> %rest:POST("{$postbody}")
> %output:method("xml")
> function soapskel:test($postbody){
> (: do all SOAP related work here :)
> <rest:forward>{
> "test/impl"
> }</rest:forward>
> };
> declare
> %rest:path("test2")
> %rest:POST("{$postbody}")
> %output:method("xml")
> function soapskel:test2($postbody){
> (: do all SOAP related work here :)
> let $id := (session:id(), session:set('data',$postbody))
> return
> <rest:forward>{
> "test/impl"
> }</rest:forward>
> };
> declare
> %rest:path("test/impl")
> %rest:POST("{$postbody}")
> %output:method("xml")
> function soapskel:impl($postbody){
> if (empty($postbody)) then
> session:get('data')
> else
> $postbody
> };
>
>
> On 01/14/2014 01:38 PM, Christian Grün wrote:
>
> Hi Marco,
>
> an introductory question: what’s your particular reason for splitting
> the operation in two parts? Do you perform database updates in the
> pre-validation step?
>
> It works nicely up to the access to the POST content which appears to be
> consumed defintely by the first function.
>
> That’s right: POST bodies can only be consumed once. We could think
> about extending the rest:forward-Syntax in order to construct a new
> body, but that’s just an idea (and I’m not sure if this is supported
> by the Java request dispatcher).
>
> Moreover there
> is no possibility of stating that the postbody may possibly be empty, is it?
>
> This should generally be possible. I have tried the following RESTXQ
> function:
>
> declare %rest:path("/post") %rest:POST("{$x}") function rest:main($x) { $x
> };
>
> It doesn’t trigger an error when calling it with:
>
> curl -XPOST -i "http://localhost:8984/post"
>
> Could you provide me with a little example of your code that causes the
> problem?
> Christian
>
>
_______________________________________________
BaseX-Talk mailing list
[email protected]
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk