node.js - 使用node-soap在soap请求中创建重复的 namespace

标签 node.js web-services soap node-soap

我正在使用node-soap在node js中调用soap请求的库。

它具有以下请求负载格式:

<soapenv:Envelope >
   <soapenv:Header/>
   <soapenv:Body>
      <typ:uploadFileToUcm>
         <typ:document>
            <erp:Content></erp:Content>
            <erp:FileName>?</erp:FileName>
            <!--Optional:-->
            <erp:ContentType>?</erp:ContentType>
            <!--Optional:-->
            <erp:DocumentTitle>?</erp:DocumentTitle>
            <!--Optional:-->
            <erp:DocumentAuthor>?</erp:DocumentAuthor>
            <!--Optional:-->
            <erp:DocumentSecurityGroup>?</erp:DocumentSecurityGroup>
            <!--Optional:-->
            <erp:DocumentAccount>?</erp:DocumentAccount>
            <!--Optional:-->
            <erp:DocumentName>?</erp:DocumentName>
            <!--Optional:-->
            <erp:DocumentId>?</erp:DocumentId>
         </typ:document>
      </typ:uploadFileToUcm>
   </soapenv:Body>
</soapenv:Envelope>

为此,我创建了参数:

var args = {
  document : {
    Content: byteArray, //create byte array to assign content
    FileName: 'Abc12341',
    ContentType: 'zip',
    DocumentTitle: 'Abc12341',
    DocumentAuthor: 'Abc12341',
    DocumentSecurityGroup: 'abc',
    DocumentAccount: 'c/c/c',
    DocumentName: 'Abc12341'
    //DocumentId :    //no data available in java file
  }
}

并将其传递为:

client.method(args, function (err, result) {

});

但是在打印 client.lastrequest 时,有效负载具有重复的命名空间,如下所示:

<soap:Body>
<types:uploadFileToUcm 
    xmlns:types="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/" 
    xmlns="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/">
    <types:document>
        <ns0:Content xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">UEsDBBQAAAAIAAuEaEue7VBfgQAAAGoBAAAcAAAASW52VHJhbnNhY3Rpb25zSW50ZXJmYWNlLmNzdvPMK0vNK8kvqlTwL0pXCA021AEBIBlgYGBsYGQK5ASXJnnmlcGkMICljmsikDIyMDTXNzTUNzBWMDCwAiMdHd/M4uTUnJzEvNT80mKFoNTk1MyCEuzG6OhYgAhfN3cdI3NLc2MDQ0MdY1MDIwMzM0McNiMBYx0jhLZBB1z9XHi5AFBLAQIUABQAAAAIAAuEaEue7VBfgQAAAGoBAAAcAAAAAAAAAAEAIAAAAAAAAABJbnZUcmFuc2FjdGlvbnNJbnRlcmZhY2UuY3N2UEsFBgAAAAABAAEASgAAALsAAAAAAA==</ns0:Content>
        <ns0:FileName 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">Abc12341</ns0:FileName>
        <ns0:ContentType 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">zip</ns0:ContentType>
        <ns0:DocumentTitle 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">Abc12341</ns0:DocumentTitle>
        <ns0:DocumentAuthor 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">Abc12341</ns0:DocumentAuthor>
        <ns0:DocumentSecurityGroup 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">FAFusionImportExport</ns0:DocumentSecurityGroup>
        <ns0:DocumentAccount 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">scm/inventoryTransaction/import</ns0:DocumentAccount>
        <ns0:DocumentName 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/" 
            xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/">Abc12341</ns0:DocumentName>
    </types:document>
    </types:uploadFileToUcm>
</soap:Body>

这里 ns0 在每个参数中重复。

问题可能出在我传递参数的方式上。

如何解决这个问题?

最佳答案

我在使用 node-soap 时遇到了同样的问题,所以我使用了不同的 Node 库,它工作得很好。尝试strong-soap,它基于node-soap,但显然是完全重写的,并且有许多相同的贡献者:https://github.com/strongloop/strong-soap .

npm install strong-soap

调用 Oracle erp 集成 SOAP API(importBulkData、uploadFileToUcm 等)的代码基本相同,但授权除外,如下所示。

var soap = require('strong-soap').soap;

var data = {};
//code to build base64 zip file goes here

var url = 'https://<host>/publicFinancialCommonErpIntegration/ErpIntegrationService?WSDL';
var args = {
    "document": {
        "Content": data,
        "FileName": "glBudgetData.zip",
        "ContentType": "zip",
        "DocumentTitle": "glBudgetData.zip",
        "DocumentAuthor": "casey.brown",
        "DocumentSecurityGroup": "FAFusionImportExport",
        "DocumentAccount": "fin$/budgetBalance$/import$",
        "DocumentName": "UCM91004"
    }
};

var options = {};

soap.createClient(url, options, function(err, client) {
    client.setSecurity(new soap.BasicAuthSecurity('casey.brown', '<your password here>'));
    client.uploadFileToUcm(args, function(err, result) {
        console.log(result);
 });

在命令行运行,输出为: { result: '2047316' } 这是导入文件的 UCM 文档 ID。

祝你好运!

关于node.js - 使用node-soap在soap请求中创建重复的 namespace ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47299272/

相关文章:

php - 我可以强制 SoapClient 将数组作为数组返回吗?

node.js - 断言错误: expected stub to have been called with arguments 201

node.js - findall 多对多 Sequelize

c# - 修饰符 'public' 对此项目无效

web-services - 使用带有身份验证的 Web 服务总是给出消息 Authentication required

.net - 从 .NET 使用 Cisco WSMA

web-services - 使用 Axis2 自定义故障代码

php - SoapFault 异常 : [HTTP] SSL support is not available in this build

node.js - 错误 : req. flash() 需要 session

javascript - 如何使用 grunt 缩小 JSON 文本文件?