我刚刚通过npm安装了包wsdl2.js,现在我不想使用它。
我的json数据有问题,因为它总是空的。
这是我的代码测试1
var Service = require('/home/valor/development/test/User');
var json = {subscriberUid : 'd7f3ea63-1118-44bb-ba97-f6f0c417313a'};
requestT = new Service.UserSoapServiceBeanPort.getSubscriber(json);
requestT.debug();
console.log(json);
requestT.request(function(err, response) {
console.log(arguments);
});
并且响应失败,因为json是空的,因为subscriberUid是必须的
{
"method": "getSubscriber",
"type": "Request",
"json": {},
"xml": "<getSubscriber></getSubscriber>",
"validates": true
}
{ subscriberUid: 'd7f3ea63-1118-44bb-ba97-f6f0c417313a' }
{
"method": "getSubscriber",
"took": 92
}
{ '0': 'Invalid response to getSubscriber' }
Process finished with exit code 0
然后我尝试按照教程/示例中的说明这样做 TEST2
var Service = require('/home/valor/development/test/User');
requestT = new Service.UserSoapServiceBeanPort.getSubscriber();
requestT.subscriberUid = 'd7f3ea63-1118-44bb-ba97-f6f0c417313a';
requestT.debug();
requestT.request(function(err, response) {
console.log(arguments);
});
再次失败的回复
/usr/local/bin/node test.js
{
"method": "getSubscriber",
"type": "Request",
"json": {},
"xml": "<getSubscriber></getSubscriber>",
"validates": true
}
{
"method": "getSubscriber",
"took": 90
}
{ '0': 'Invalid response to getSubscriber' }
Process finished with exit code 0
测试3
var service = require("/home/valor/development/test/user");
service.Settings.debugSoap = true;
var request = new service.UserSoapServiceBeanPort.getSubscriber();
console.log(request);
console.log(request.subscriberUid = 'd7f3ea63-1118-44bb-ba97-f6f0c417313a');
request.subscriberUid = 'd7f3ea63-1118-44bb-ba97-f6f0c417313a'
request.debug();
响应
/usr/local/bin/node test.js
{ getSubscriber: [Getter/Setter] }
d7f3ea63-1118-44bb-ba97-f6f0c417313a
{
"method": "getSubscriber",
"type": "Request",
"json": {},
"xml": "<getSubscriber></getSubscriber>",
"validates": true
}
Process finished with exit code 0
我发现的另一件奇怪事情是
console.log(Service.UserSoapServiceBeanPort.getSubscriber);
[Function]
,而
console.log(Service.UserSoapServiceBeanPort.getSubscriber());
undefined
现在我不知道我还能做什么,所以我希望你们能帮助我 提前谢谢
答案 0 :(得分:0)
在与wsdl2.js开发人员交谈之后,我们发现wsdl2.js不支持在工作代码中转换我们的WSDL,因为它与标准的稍有不同。我们使用xs:elements,而wsdl2.js可以转换xsd:elements