node.js - 在 Mantis 中以编程方式创建问题

标签 node.js soap soap-client

我正在编写一个小的node.js 脚本,该脚本将运行多个命令,如果任何一个命令失败,它将报告 Mentis 上的问题。我正在使用以下代码来报告 mantis bugtracker 中的问题。 Mantis bug tracker 附带了一堆 SOAP api 来完成类似的事情。 http://www.mantisbt.org/bugs/api/soap/mantisconnect.php?wsdl#op.idp90022480

var soap = require('soap');
  var url = 'http://localhost/mantisbt-1.2.19/api/soap/mantisconnect.php?wsdl';
  var user = 'administrator';
  var password = 'root';
  var args = {
        username: user, 
        password: password,         
        project: {
            id: 1
        },
        category: 'General',
        summary: 'Test summary', 
        description: 'test description'
    };  

  soap.createClient(url, function(err, client) {

      client.mc_issue_add(args, function(err1, result) {
        if(err1)
            console.log( err1 );
        else
            console.log('Issue successfully created');
      });

  });

但我收到以下错误日志:

<faultstring>Project \'\' does not exist.</faultstring>

我有一个 id 1 的项目,我可以使用 php 创建具有相同数据的问题。我的理解是项目 ID 没有正确发送。等效的php代码如下。

$c = new SoapClientDebug("http://localhost/mantisbt-1.2.19/api/soap/mantisconnect.php?wsdl", ['trace' => true]);

$username = 'administrator';
$password = 'root';
$issue = array ( 
    'summary' => 'PHP test issue', 
    'description' => 'PHP test description', 
    'project'=> array(      
        'id'=>1     
    ), 
    'category'=>'General',
);
$c->mc_issue_add($username, $password, $issue);

PHP 代码可以正常运行。

最佳答案

你的参数应该是这样的:

var args = {
    username: user, 
    password: password,
    issue: {         
      project: {
        id: 1
      },
      category: 'General',
      summary: 'Test summary', 
      description: 'test description'
    }
};  

关于node.js - 在 Mantis 中以编程方式创建问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28956246/

相关文章:

javascript - Node JS : SOAP to query Java Web Services

javascript - Nodejs如何独立检查PID正在运行的进程?

node.js - 检查网站是否可联系

node.js - 到 stdout 的 Node 管道——如何判断是否耗尽?

xml - 如何解释 WSDL 来手动创建 XML SOAP 请求?

PHP SOAP 请求不正确

java - 使用 Maven 的 Soap 客户端

javascript - 在 Express + NodeJS 应用程序的 Controller 中使用 ES6 类或对象文字

soap - 使用 SOAP 公开 CRUD 操作

javascript - 如何发送 SOAP 请求并使用 HTML 接收响应?