Я пытаюсь вызвать службы Javaweb из модуля node js. Однако я получаю ошибку в библиотеке wsdl. Вот мой файл wsdl.
<!--
Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e.
--><!--
Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e.
--><definitions targetNamespace = "http://jaxws.joshis1.com/" name = "webServiceImplService"><types><xsd:schema><xsd:import namespace = "http://jaxws.joshis1.com/" schemaLocation = "http://localhost:8888/webservice/helloworld?xsd=1"/></xsd:schema></types><message name = "sayHello"><part name = "parameters" element = "tns:sayHello"/></message><message name = "sayHelloResponse"><part name = "parameters" element = "tns:sayHelloResponse"/></message><portType name = "IwebServiceInterface"><operation name = "sayHello"><input wsam:Action = "http://jaxws.joshis1.com/IwebServiceInterface/sayHelloRequest" message = "tns:sayHello"/><output wsam:Action = "http://jaxws.joshis1.com/IwebServiceInterface/sayHelloResponse" message = "tns:sayHelloResponse"/></operation></portType><binding name = "webServiceImplPortBinding" type = "tns:IwebServiceInterface"><soap:binding transport = "http://schemas.xmlsoap.org/soap/http" style = "document"/><operation name = "sayHello"><soap:operation soapAction = ""/><input><soap:body use = "literal"/></input><output><soap:body use = "literal"/></output></operation></binding><service name = "webServiceImplService"><port name = "webServiceImplPort" binding = "tns:webServiceImplPortBinding"><soap:address location = "http://localhost:8888/webservice/helloworld"/></port></service></definitions>
Вот мой test.js
var soap = require('soap');
var url = 'http://localhost:8888/webservice/helloworld?wsd';
var args = {sayHello: 'ABC'};
soap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result) {
console.info(result);
});
});
При запуске я получаю следующую ошибку -
node_modules/soap/lib/wsdl.js:68
const [topLevelName] = nsName.split('|');
^
SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
$ node --version v4.2.6
Есть ли другой способ, как jquery, для вызова этой веб-службы Java?
node test.js
/home/sjoshi/test.js:5
client.sayHello(args, function(err, result) {
^
TypeError: Cannot read property 'sayHello' of undefined



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


Какую версию Node.js вы используете? Я считаю, что деструктуризация массива - новая функция, поэтому, если вы используете старую версию Node.js, она может не иметь этой функции.
http://kangax.github.io/compat-table/es6/#node6_5
Похоже, что Node 6.5 и выше его поддерживает.
но я получаю еще одну ошибку, например, свойство, которое оно не может прочитать.
Таким образом, пакет, который вы пытаетесь использовать, похоже, ожидает более новой версии Node, поэтому попробуйте выполнить обновление. Причина того, что TypeError: Cannot read property 'sayHello' of undefined на client, заключается в том, что client никогда не создается правильно из-за первой ошибки. После обновления Node обе проблемы должны быть решены.
$ node - версия v4.2.6