Узел JS: SOAP для запроса веб-служб Java - PullRequest
0 голосов
/ 20 декабря 2018

Я пытаюсь вызвать службы Javaweb из модуля 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.log(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)

$ узел--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

1 Ответ

0 голосов
/ 20 декабря 2018

Какую версию Node.js вы используете?Я полагаю, что деструктуризация массива - более новая функция, поэтому, если вы используете более старую версию Node.js, она может не иметь этой функции.

http://kangax.github.io/compat-table/es6/#node6_5

Похоже, что Node 6.5 иUp поддерживает это.

...