【问题标题】:Marklogic 6 , Calling Resource Extension in javaMarklogic 6,在java中调用资源扩展
【发布时间】:2016-04-05 14:00:45
【问题描述】:

我需要上传并使用 xquery 模块到 ma​​rklogic 6,例如 check-docAvailable.xqy。我尝试使用 ML6 给出的 dictionary.xqy 示例,效果很好。但是当我尝试导入自己的 xquery 时,我遇到了错误。

ERROR :
Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: config/resources write failed: Internal Server Error. Server Message: XDMP-IMPORTMOD: Cannot import Main Module /marklogic.rest.resource/dictionary/lib/resource.xqy.  See the MarkLogic server error log for further detail.
    at com.marklogic.client.impl.JerseyServices.putPostValueImpl(JerseyServices.java:2033)
    at com.marklogic.client.impl.JerseyServices.putValue(JerseyServices.java:1918)
    at com.marklogic.client.impl.ResourceExtensionsImpl.writeServices(ResourceExtensionsImpl.java:114)
    at com.mobius.ln.ml.util.MLUtil$DictionaryManager.installResourceExtensionShortcut(MLUtil.java:279)
    at com.mobius.ln.ml.util.MLUtil.main(MLUtil.java:202)

我的 Xquery 模块:

xquery version "1.0-ml";
declare namespace xs = "http://www.w3.org/2001/XMLSchema";
declare variable $uri as xs:string external;

let $uri := $uri
return (
fn:doc-available($uri)
)

请建议我如何实现这一目标。 Xquery 有错误吗?

【问题讨论】:

  • "请参阅 MarkLogic 服务器错误日志以获取更多详细信息。" -- 你这样做了吗?

标签: java xquery marklogic


【解决方案1】:

我建议通读Extending the REST API。您的 XQuery 模块看起来不像 REST 扩展。当我尝试通过 curl 安装您的模块时

curl --anyauth --user admin:admin -i \
  -H "Content-type: application/xquery" \
  --data-binary @/c/temp/a.xqy \
  -X PUT http://localhost:8000/LATEST/config/resources/a

我收到以下错误:

{"errorResponse":{"statusCode":400, "status":"Bad Request", "messageCode":"RESTAPI-INVALIDCONTENT", "message":"RESTAPI-INVALIDCONTENT: (err:FOER0000) 无效内容:无效扩展:无法解析 XQuery 扩展 a;有关详细信息,请参阅服务器错误日志 XDMP-IMPORTMOD:无法导入主模块 /marklogic.rest.resource/a/assets/resource.xqy;要么不是有效模块或者在http://marklogic.com/rest-api/resource/a命名空间中不提供扩展功能(delete、get、put、post)"}}

【讨论】:

  • 谢谢 sam,我会重写我的 xquery 并检查一下。
【解决方案2】:

这部分错误信息看起来很重要:

XDMP-IMPORTMOD:无法导入主模块 /marklogic.rest.resource/dictionary/lib/resource.xqy。

看起来您使用 REST API 将 dictionary.xqy 部署为服务扩展,然后尝试将该模块导入另一个模块。 dictionary.xqy 显然是一个主模块,但只能导入库模块。有关更多信息,请参阅 Application Developer's Guide 中的 XQuery Library Modules and Main Modules

我认为您正在将主模块部署为服务扩展,但此类扩展必须是库模块。查看 REST Application Developer's Guide 中的 Guidelines for Writing XQuery Resource Service Extensions,注意 Resource Extension Interface section

解决方案:使用所需的接口将您的扩展程序重写为库模块。

【讨论】:

  • 谢谢 Dave,我会重写我的 xquery 并检查
猜你喜欢
  • 1970-01-01
  • 2020-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-28
  • 2018-12-15
  • 1970-01-01
相关资源
最近更新 更多