code:
var soap = require(‘soap’); var url = ‘http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl’; var endpoint = ‘http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx’;
var args = {qqCode:“123456”};
soap.createClient(url, function(err, client){ client.qqCheckOnline(args, function(err, result) { console.log(result.qqCheckOnlineResult); }); },endpoint);
环境: nodejs 0.8.16 soap-0.2.7
大家有遇到过吗?怎么解决?
错误提示:
module.js:340 throw err; ^ Error: Cannot find module 'soap’ at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:362:17) at require (module.js:378:17) at Object.<anonymous> (F:\desktop\nodejs\untitled\app.js:8:12) at Module._compile (module.js:449:26) at Object.Module._extensions…js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10)
不填endpoint也是一样错误
sorry 上面的贴错 错误是:
F:\desktop\nodejs\untitled>app
assert.js:102 throw new assert.AssertionError({ ^ AssertionError: Invalid child type at DefinitionsElement.addChild (F:\desktop\nodejs\untitled\node_modules\soap \lib\wsdl.js:319:9) at Element.endElement (F:\desktop\nodejs\untitled\node_modules\soap\lib\wsdl .js:109:20) at WSDL._parse (F:\desktop\nodejs\untitled\node_modules\soap\lib\wsdl.js:917 :13) at EventEmitter.emit (events.js:96:17) at Parser.parse (F:\desktop\nodejs\untitled\node_modules\soap\node_modules\n ode-expat\lib\node-expat.js:18:22) at WSDL._parse (F:\desktop\nodejs\untitled\node_modules\soap\lib\wsdl.js:920 :12) at WSDL._fromXML (F:\desktop\nodejs\untitled\node_modules\soap\lib\wsdl.js:9 28:29) at WSDL (F:\desktop\nodejs\untitled\node_modules\soap\lib\wsdl.js:584:18) at process.startup.processNextTick.process._tickCallback (node.js:244:9)
F:\desktop\nodejs\untitled>
根据https://github.com/milewise/node-soap/issues/57提出的解决方案 的确解决了错误问题,可是也提示:未将对象引用设置到对象的实例
我对js不熟悉 不知道var args = {qqCode:“123456”};这个写不对马?
php测试代码:$result = $soap->qqCheckOnline(array(‘qqCode’ => ‘1312323’)); 测试通过
另外我也看到你的另外一个文章 似乎也是在说这个问题的?
抓包发现: php: <?xml version=“1.0” encoding=“UTF-8”?> -<SOAP-ENV:Envelope xmlns:ns1=“http://WebXml.com.cn/” xmlns:SOAP-ENV=“http://schemas.xmlsoap.org/soap/envelope/”>-SOAP-ENV:Body-ns1:qqCheckOnlinens1:qqCode1312323</ns1:qqCode></ns1:qqCheckOnline></SOAP-ENV:Body></SOAP-ENV:Envelope>
nodejs: <?xml version=“1.0”?> -<soap:Envelope xmlns:tns=“http://WebXml.com.cn/” xmlns:tm=“http://microsoft.com/wsdl/mime/textMatching/” xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>soap:Header/-soap:Body-tns:qqCheckOnline<qqCode>123456</qqCode></tns:qqCheckOnline></soap:Body></soap:Envelope>
谢谢了!问题解决了,看来维护者还有很多工作要做,这个东西还是不能直接用在产品当中的