首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Marklogic 9+ Roxy:无法连接到使用Node.js创建的数据库

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

Stack Overflow用户
提问于 2017-10-30 15:22:49
回答 1查看 105关注 0票数 1

我在试用Roxy部署人员。Roxy应用程序是使用默认应用程序类型创建的。我建立了一个新的ML 9数据库,并使用默认端口(8040和8041)运行"ml本地引导程序“。

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

代码语言:javascript
复制
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));
  });

运行脚本会给我一个错误,比如:

代码语言:javascript
复制
$ 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 (插入文档的默认appserver ),节点函数将按预期正确执行。我不确定是否需要用Roxy创建的appserver配置其他任何内容,以便它能够与node.js应用程序一起工作。

我不知道错误消息中的"DELETE_IF_UNUSED“部分是从哪来的。Roxy生成的配置文件中似乎没有这样的文本。

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

代码语言:javascript
复制
<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。这也是一个新的安装。

有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-30 18:24:02

基于这些注释,问题似乎是Node.js客户端API期望与REST端点对话,但是默认的Roxy配置是一个MVC应用程序。如果你还没有对你的Roxy应用做任何重要的事情,我会删除它,用--app-type=rest创建一个。

代码语言:javascript
复制
$ ml new my-app --app-type=rest --server-version=9
$ ml local bootstrap
$ ml local deploy modules

那就试试你的Node应用程序。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47018820

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档