node soap模块

官方文档:https://www.npmjs.com/package/soap

Install

npm install soap

方法

  • soap.createClient(url[, options], callback)
  var soap = require('soap');
  var url = 'http://example.com/wsdl?wsdl';
  var args = {name: 'value'};
  soap.createClient(url, function(err, client) {
      client.***(args, function(err, result) {
          console.log(result);
      });
  });
  • soap.createClientAsync(url[, options])
  var soap = require('soap');
  var url = 'http://example.com/wsdl?wsdl';
  var args = {name: 'value'};
  soap.createClientAsync(url).then((client) => {
    return client.['***' + 'Async'](args);
  }).then((result) => {
    console.log(result);
  });

options参数(有以下几个):

  • endpoint: to override the SOAP service's host specified in the .wsdl file.(不懂)
  • envelopeKey: to set specific key instead of <pre><soap:Body></soap:Body></pre>.(不懂)
  • preserveWhitespace: 保留text and cdata前后的空格
  • escapeXML: 将SOAP信息中特殊的XML符号escape编码处理,例如&, >, <等,属性值默认为true
  • suppressStack: suppress the full stack trace for error messages.
  • returnFault: 对于错误请求,返回一个无效的XMLSOAP,默认为false
  • forceSoap12Headers: 将消息头强制设置成SOAP1.2
  • httpClient: to provide your own http client that implements request(rurl, data, callback, exheaders, exoptions).(提供你自己的http请求。。。不懂)
  • request: 重写request模块.
  • wsdl_headers: 在WSDL请求中自定义发送的HTTP头.
  • wsdl_options: 在WSDL请求中为request模块自定义选项.
  • disableCache: 不缓存WSDL文件,每次都重新请求.
  • overridePromiseSuffix: 如果你的WSDL操作包含Async后缀,你需要去重写一个特定的后缀,选项默认为Async
  • normalizeNames: if your wsdl operations contains names with non identifier characters ([^a-z$_0-9]), replace them with _. Note: if using this option, clients using wsdls with two operations like soap:method and soap-method will be overwritten. Then, use bracket notation instead (client['soap:method']()).(不懂)
  • namespaceArrayElements: provides support for nonstandard array semantics. If true, JSON arrays of the form {list: [{elem: 1}, {elem: 2}]} are marshalled into xml as <list><elem>1</elem></list> <list><elem>2</elem></list>. If false, marshalls into <list> <elem>1</elem> <elem>2</elem> </list>. Default: true.(不懂)
    !!!0.10.X以上版本的node,要增加这个参数{connection: 'keep-alive'}避免截断了过长的请求
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,181评论 0 10
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 13,216评论 0 13
  • 生活中是一个很容易有很多感慨的人。 一个在学校宿舍的小故事,舍友在周末后收拾宿舍,垃圾筐的垃圾都满了并且地上也都堆...
    小象_3c09阅读 1,103评论 0 0
  • 抬头仰望天空的飞机 飞着纸飞机 做着梦 低头看那曾经的仰望的男孩 飞机飞了好久 很累了吧 那仰望的男孩 也累了吧 ...
    小生不才_sy阅读 1,679评论 1 3

友情链接更多精彩内容