nodejs - 使用npm package strong soap,SOAP调用失败,出现500错误

时间:2018-03-28 04:07:01

标签: node.js soap wsdl strong-soap

我正在尝试利用npm strong-soap包在nodejs中执行SOAP调用。

我收到如下错误(前面几行错误)

"statusCode":500,"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<SOAP-ENV:
Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">\n    <SOA
P-ENV:Body>\n        <SOAP-ENV:Fault>\n            <faultcode>BWENGINE-100031</f
aultcode>\n            <faultstring>Output data invalid</faultstring>\n
   <faultactor>JOBID_15734</faultactor>\n            <detail>\n                <
ns0:Error_Short_Message xmlns:ns0=\"http://xmlns.example.com/unique/default/name
space/1073503881527\">\n                    <ns0:key>JOBID_15734</ns0:key>\n
                <ns0:msg_code>BWENGINE-100031</ns0:msg_code>\n
  <ns0:message>Output data invalid</ns0:message>\n 

客户端代码如下:

var soap = require('strong-soap').soap;
 var url = 'D:/Workspace/Projects/Sample.wsdl';
  var args = {arg1: '6564',arg2:'ONE'};
    var soapHeader = {
        'header1': 'value1',
        'header2': 'value2',
        'header3': 'value3',
    };
var options = {};
  soap.createClient(url,options,function (err, client) {
      client.setEndpoint('http://hostname:Port/SampleService/Service');
      var method = client['GetDataMethod'];
      method(args,function (err, result, envelope, soapHeader) {
          //response envelope
          //console.log('Response Envelope: \n' + envelope);
          //'result' is the response body
          console.log('Result: \n' + JSON.stringify(result));
      })
  });

有关此错误原因的任何建议都会有所帮助。

UPDATE:

如果我按照以下方式构建args,我能够触发请求并获得响应:

var args = {
   "namespace":{
        "requestHeader":{
            "header1": "value1",
            "header2": "value2",
            "header3": "value3"
            },
        "arg1": "6564",
        "arg2":"ONE"}
   };

但是为什么strong-soap无法根据wsdl内容设置命名空间?以编程方式识别wsdl中20-30个命名空间中的确切命名空间似乎是一项繁琐的任务。

0 个答案:

没有答案