Marklogic 9 + Roxy:无法使用 Node.js 连接到创建的数据库

Marklogic 9 + Roxy: can't connect to created database using Node.js

我正在试用 Roxy 部署器。 Roxy 应用程序是使用默认应用程序类型创建的。我设置了一个新的 ML 9 数据库,并且我 运行 "ml local bootstrap" 使用默认端口(8040 和 8041)

然后我设置了一个节点应用程序。我尝试了以下(来自 https://docs.marklogic.com/jsdoc/index.html 的示例代码)

var marklogic = require('marklogic');
var conn = {
    host: '192.168.33.10',  
    port: 8040,
    user: 'admin',
    password: 'admin',
    authType: 'DIGEST'
}

var db = marklogic.createDatabaseClient(conn);

db.createCollection(
  '/books',
  {author: 'Beryl Markham'},
  {author: 'WG Sebald'}
  )
.result(function(response) {
    console.log(JSON.stringify(response, null, 2));
  }, function (error) {
    console.log(JSON.stringify(error, null, 2));
  });

运行 脚本给了我这样的错误:

$ node test.js
{
  "message": "write document list: cannot process response with 500 status",
  "statusCode": 500,
  "body": "<error:error xsi:schemaLocation=\"http://marklogic.com/xdmp/error error.xsd\" xmlns:error=\"http://marklogic.com/xdmp/error\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n  <error:code>XDMP-IMPMODNS</error:code>\n  <error:name>err:XQST0059</error:name>\n  <error:xquery-version>1.0-ml</error:xquery-version>\n  <error:message>Import module namespace mismatch</error:message>\n  <error:format-string>XDMP-IMPMODNS: (err:XQST0059) Import module namespace http://marklogic.com/rest-api/endpoints/config does not match target namespace http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED of imported module /MarkLogic/rest-api/endpoints/config.xqy</error:format-string>\n  <error:retryable>false</error:retryable>\n  <error:expr/>\n  <error:data>\n    <error:datum>http://marklogic.com/rest-api/endpoints/config</error:datum>\n    <error:datum>http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED</error:datum>\n    <error:datum>/MarkLogic/rest-api/endpoints/config.xqy</error:datum>\n  </error:data>\n  <error:stack>\n    <error:frame>\n      <error:uri>/roxy/lib/rewriter-lib.xqy</error:uri>\n      <error:line>5</error:line>\n      <error:column>0</error:column>\n      <error:xquery-version>1.0-ml</error:xquery-version>\n    </error:frame>\n  </error:stack>\n</error:error>\n"
}

如果我将端口更改为 8000(插入到 Documents 中的默认应用程序服务器),节点功能将按预期正确执行。我不确定是否需要使用 Roxy 创建的应用程序服务器配置任何其他内容,以便它与 node.js 应用程序一起使用。

我不确定错误消息中的 "DELETE_IF_UNUSED" 部分来自哪里。 Roxy生成的配置文件里好像没有这样的文字。

编辑:当通过浏览器访问 192.168.33.10:8040 时,我得到一个 xml 类似的错误:

<error:error xsi:schemaLocation="http://marklogic.com/xdmp/error error.xsd" xmlns:error="http://marklogic.com/xdmp/error" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <error:code>XDMP-IMPMODNS</error:code>
  <error:name>err:XQST0059</error:name>
  <error:xquery-version>1.0-ml</error:xquery-version>
  <error:message>Import module namespace mismatch</error:message>
  <error:format-string>XDMP-IMPMODNS: (err:XQST0059) Import module namespace http://marklogic.com/rest-api/endpoints/config does not match target namespace http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED of imported module /MarkLogic/rest-api/endpoints/config.xqy</error:format-string>
  <error:retryable>false</error:retryable>
  <error:expr/>
  <error:data>
    <error:datum>http://marklogic.com/rest-api/endpoints/config</error:datum>
    <error:datum>http://marklogic.com/rest-api/endpoints/config_DELETE_IF_UNUSED</error:datum>
    <error:datum>/MarkLogic/rest-api/endpoints/config.xqy</error:datum>
  </error:data>
  <error:stack>
    <error:frame>
      <error:uri>/roxy/lib/rewriter-lib.xqy</error:uri>
      <error:line>5</error:line>
      <error:column>0</error:column>
      <error:xquery-version>1.0-ml</error:xquery-version>
    </error:frame>
  </error:stack>
</error:error>

如果重要的话,MarkLogic 版本是 9.0-3.1。这也是全新安装。

有什么建议吗?

根据评论,问题似乎出在 Node.js 客户端 API 期望与 REST API 端点对话,但默认的 Roxy 配置是 MVC应用。如果您还没有对您的 Roxy 应用程序做任何重要的事情,我会删除它并使用 --app-type=rest 创建一个。

$ ml new my-app --app-type=rest --server-version=9
$ ml local bootstrap
$ ml local deploy modules

然后尝试您的 Node 应用程序。