Marklogic 6,在java中调用资源扩展

时间:2016-04-05 14:00:45

标签: java xquery marklogic

我需要将xquery模块上传并使用 marklogic 6 ,例如check-docAvailable.xqy。我尝试使用ML6给出的dictionary.xqy样本,效果很好。但是当我尝试导入我自己的xquery时,我得到了以下错误。

current-input-port

我的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有什么错误吗?

2 个答案:

答案 0 :(得分:4)

我建议阅读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”:“错误请求”,“messageCode”:“RESTAPI-INVALIDCONTENT”,“message”:“RESTAPI-INVALIDCONTENT :(错误:FOER0000)内容无效:扩展名无效:无法解析XQuery扩展名a;请参阅服务器错误日志以获取详细信息XDMP-IMPORTMOD:无法导入主模块/marklogic.rest.resource/a/assets/resource.xqy;其中一个不是有效模块或者不在http://marklogic.com/rest-api/resource/a命名空间中提供扩展功能(删除,获取,放置,发布)}}

答案 1 :(得分:3)

错误消息的这一部分看起来很重要:

  

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应用程序开发人员指南中查看Guidelines for Writing XQuery Resource Service Extensions,注意Resource Extension Interface section

解决方案:使用所需的界面将扩展名重写为库模块。