如何在 MarkLogic XQuery 中获取 HTTP POST body?

How do I get the HTTP POST body in MarkLogic XQuery?

我正在尝试使用 exist-db request:get-data() 方法来获取请求的 post 数据。但是,我收到错误消息:

XDMP-UNDFUN: (err:XPST0017) Undefined function request:get-data()

我确实在 header 中声明了命名空间。我不明白为什么我仍然不能使用 request:get-data() 或任何其他请求:functions

declare namespace request="http://exist-db.org/xquery/request";
declare option exist:serialize "method=xml media-type=text/xml indent=yes";

let $post-data := request:get-data()
return $post-data

我想你正在寻找 xdmp:get-request-body

Sam 指出了您需要的功能,但我想回答您问题的另一部分:

I did declare the namespace in my header. I don't understand why I still can't use request:get-data() or any of the other request: functions

每个 XQuery 处理引擎 implements standard functions,但还需要标准未定义的其他功能。对于 MarkLogic,您将使用带有 fn: 前缀的标准函数。

然后每个 XQuery 引擎定义将需要的附加函数。对于 Exist DB,其中一些在“http://exist-db.org/xquery/request" namespace, while MarkLogic uses "http://marklogic.com/xdmp”中用于它的许多扩展功能。

当您寻找与 Exist DB 特定函数等效的 MarkLogic 时,请搜索 http://docs.marklogic.com——从函数名称开始,如果不起作用,请搜索符合以下条件的术语描述你想做什么。