简体   繁体   English

如何在MarkLogic XQuery中获取HTTP POST主体?

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

I'm trying to use the exist-db request:get-data() method to get the post data of a request. 我正在尝试使用exists-db request:get-data()方法来获取请求的发布数据。 However, I'm getting the error: 但是,我收到错误:

XDMP-UNDFUN: (err:XPST0017) Undefined function request:get-data() XDMP-UNDFUN :(错误:XPST0017)未定义的函数请求:get-data()

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 我不明白为什么我仍然不能使用request:get-data()或任何其他请求:函数

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 pointed you to the function you need, but I wanted to respond to another part of your question: 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 我不明白为什么我仍然不能使用request:get-data()或任何其他请求:函数

Each XQuery processing engine implements standard functions , but there is other functionality needed that is not defined by the standard. 每个XQuery处理引擎都实现标准功能 ,但还需要标准未定义的其他功能。 For MarkLogic, you'll use standard functions with the fn: prefix. 对于MarkLogic,您将使用带有fn:前缀的标准函数。

Each XQuery engine then defines additional functions that will be needed. 然后,每个XQuery引擎都定义了所需的其他功能。 For Exist DB, some of those are in the " http://exist-db.org/xquery/request " namespace, while MarkLogic uses " http://marklogic.com/xdmp " for a lot of its extension functions. 对于Exist DB,其中一些位于“ http://exist-db.org/xquery/request ”命名空间中,而MarkLogic使用“ http://marklogic.com/xdmp ”来实现其许多扩展功能。

When you're looking for the MarkLogic equivalent of an Exist DB-specific function, search on http://docs.marklogic.com -- start with the function name, and if that doesn't work, search for the terms that describe what you're trying to do. 当您在寻找与Exist DB特定功能相当的MarkLogic时,请在http://docs.marklogic.com上搜索 - 从函数名称开始,如果这不起作用,请搜索描述的术语你想做什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM