首先安裝soap模塊web
npm install soapnpm
var soap = require('soap'); var url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl'; var args = { byProvinceName: '江蘇'}; exports.soaptest = function(){soap.createClient(url, function(err, client) { client.setSOAPAction("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity"); client.getSupportCity(args, function(err, result) { console.log(result); }); }); }
在模塊lib中找到client.js
ui
修改:this
soapAction = this.SOAPAction ? this.SOAPAction(ns, name) : (method.soapAction || (((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + name)),
爲:url
soapAction = method.soapAction || (((ns.lastIndexOf("/") != ns.length - 1) ? ns + "/" : ns) + name),
調用返回數據:spa
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://WebXml.com.cn/"> <string>南京 (58238)</string> <string>蘇州 (58357)</string> <string>崑山 (58356)</string> <string>南通 (58259)</string> <string>太倉 (58377)</string> <string>吳縣 (58349)</string> <string>徐州 (58027)</string> <string>宜興 (58346)</string> <string>鎮江 (58248)</string> <string>淮安 (58145)</string> <string>常熟 (58352)</string> <string>鹽城 (58151)</string> <string>泰州 (58246)</string> <string>無錫 (58354)</string> <string>連雲港 (58044)</string> <string>揚州 (58245)</string> <string>常州 (58343)</string> <string>宿遷 (58131)</string> </ArrayOfString>