Javascript 向node.js(节点SOAP)中的SOAP消息添加属性

Javascript 向node.js(节点SOAP)中的SOAP消息添加属性,javascript,node.js,soap,soap-client,node-soap,Javascript,Node.js,Soap,Soap Client,Node Soap,我花了最后一天的时间来敲打我的头,如果有任何帮助,我将不胜感激 我正在构建一个使用第三方SOAPWeb服务的应用程序。这是基于node.js并使用节点soap的。不幸的是,WSDL文件有点不完整,我需要解决这个问题 这是我正在使用的代码: var url = 'http://domainexample.com/ws/connectionService.cfc?wsdl'; var session = 'super secret string' var args = { connectionID:

我花了最后一天的时间来敲打我的头,如果有任何帮助,我将不胜感激

我正在构建一个使用第三方SOAPWeb服务的应用程序。这是基于node.js并使用节点soap的。不幸的是,WSDL文件有点不完整,我需要解决这个问题

这是我正在使用的代码:

var url = 'http://domainexample.com/ws/connectionService.cfc?wsdl';
var session = 'super secret string'
var args = { connectionID: session }

soap.createClient(url, function (err, client) {
    client.connectionService_wrapService['connectionservice.cfc'].isConnected(args, function (err, result) {
        console.log(result);
    });
});
这就是我得到的错误。大多数其他方法都很有效:

org.xml.sax.SAXException:反序列化参数“connectionID\”:找不到类型的反序列化程序{ }任意类型'

这是该方法生成的消息:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:impl="http://rpc.xml.cfml/
ws/ConnectionService.cfc" xmlns:intf="http://rpc.xml.cfml/ws/ConnectionService.cfc">
  <soap:Body>
    <impl:isConnected>
      <connectionID>super secret string</connectionID>
    </impl:isConnected>
  </soap:Body>
</soap:Envelope>
我得到以下信息:

<impl:isConnected>
  <test>
    <connectionID xsi:type="xsd:string">super secret string</connectionID>
  </test>
</impl:isConnected>
所以我得到这个:

<impl:isConnected>
    <connectionID xsi:type="xsd:string">super secret string</connectionID>
</impl:isConnected>

超机密字符串
但这似乎没有发生。事实上,当我将类型属性保留到单个节点时,它根本没有添加类型属性。我还需要找出在调用中添加额外模式的方法。我通过在soap节点核心代码中手动添加它来解决这个问题,但这一点也不干净(尽管我可以接受)

有什么想法吗?我对肥皂相当陌生,目前运气不太好


谢谢

我确定了几件事: 我在wsdl定义中包括了以下名称空间:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
此外,在响应中,请确保信封中包含以下命名空间:

xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
我还必须手动修复节点soap库中以下位置lib/wsdl.js wsdl.prototype处的两个问题

我添加了以下代码以实现这一点:

WSDL.prototype._xmlnsMap = function() {
    var xmlns = this.definitions.xmlns;
    var str = '';
    for (var alias in xmlns) {
      if (alias === '' || alias === TNS_PREFIX) {
        continue;
      }
      var ns = xmlns[alias];
      switch (ns) {
        case "http://www.w3.org/2001/XMLSchema-instance" : //xsi support
        case "http://www.w3.org/2001/XMLSchema" : //xsd support
          str += ' xmlns:' + alias + '="' + ns + '"';
          continue;
        case "http://xml.apache.org/xml-soap" : // apachesoap
        case "http://schemas.xmlsoap.org/wsdl/" : // wsdl
        case "http://schemas.xmlsoap.org/wsdl/soap/" : // wsdlsoap
        case "http://schemas.xmlsoap.org/wsdl/soap12/": // wsdlsoap12
        case "http://schemas.xmlsoap.org/soap/encoding/" : // soapenc
          continue;
      }
      if (~ns.indexOf('http://schemas.xmlsoap.org/')) {
        continue;
      }
      if (~ns.indexOf('http://www.w3.org/')) {
        continue;

      }
      if (~ns.indexOf('http://xml.apache.org/')) {
        continue;
      }
      str += ' xmlns:' + alias + '="' + ns + '"';
    }
    return str;
  };
最新答复:

<soap:Body><IsAliveResponse><return xsi:type="xsd:string">success</return>
</IsAliveResponse></soap:Body>

当前,节点Soap不允许在客户端选项中传递“attributesKey”值,默认情况下不使用该值

我能让它工作的唯一方法是定义我自己的WSDL对象(使用open_WSDL(uri,options,callback)函数),在第二个参数处传递选项(不包括“attributesKey”,因为它不会分配它),然后像这样分配给生成的对象:

var args = {
    connectionID:
    {
        attributes: {
            'xsi:type': 'xsd:string'
        },
        $value: session
    }
};
open_wsdl(wsdlUrl, setupSoapWsdlConfig() /* Here you can pass other params as valueKey and xmlKey but not attributesKey */, (err, wsdl: WSDL) => {
   if ( err ) { reject(err); }
   this.wsdl = wsdl;
   wsdl.options.attributesKey = '$attributes'; // Specify attributesKey
   resolve(wsdl);
});

我也有同样的问题,你是怎么解决的
<soap:Body><IsAliveResponse><return xsi:type="xsd:string">success</return>
</IsAliveResponse></soap:Body>
return:{
    attributes: {
        'xsi:type': 'xsd:string'
    },
    $value: healthCheck
}
open_wsdl(wsdlUrl, setupSoapWsdlConfig() /* Here you can pass other params as valueKey and xmlKey but not attributesKey */, (err, wsdl: WSDL) => {
   if ( err ) { reject(err); }
   this.wsdl = wsdl;
   wsdl.options.attributesKey = '$attributes'; // Specify attributesKey
   resolve(wsdl);
});