[英]RestXQ [XPTY0004] Cannot convert empty-sequence() to document-node()
I have a RestXQ method: 我有一个RestXQ方法:
declare
%rest:path("/doSomething")
%rest:POST
%rest:form-param("name","{$name}")
function page:doSomething($name as document-node())
{
(: Code... :)
};
I tried to send a POST request to this method via XForms. 我试图通过XForms向此方法发送POST请求。 As response on the client I get
[XPTY0004] Cannot convert empty-sequence() to document-node(): ().
作为对客户端的响应,我得到
[XPTY0004] Cannot convert empty-sequence() to document-node(): ().
I tried to remove document-node()
but then the parameter $name is just empty. 我试图删除
document-node()
但是参数$ name只是空的。
The request parameter looks like this: request参数如下所示:
<data xmlns=""><name>Test</name></data>
Any solutions? 有什么办法吗?
The problem is that %rest:form-param("name","{$name}")
is for key-value pairs, but your method indicates that you want $name as document-node()
. 问题是
%rest:form-param("name","{$name}")
用于键-值对,但是您的方法表明您希望$name as document-node()
。 Those two things together don't make sense. 这两件事加在一起是没有意义的。
Instead of the form-param
you likely want the body of the POST request, for that you would use the following: 您可能需要使用POST请求的正文,而不是
form-param
:
declare
%rest:path("/doSomething")
%rest:POST("{$body}")
function page:doSomething($body as document-node())
{
(: Code... :)
};
See http://www.adamretter.org.uk/papers/restful-xquery_january-2012.xhtml#media-example 参见http://www.adamretter.org.uk/papers/restful-xquery_january-2012.xhtml#media-example
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.