Вызвать Jax-ws SOAP на основе веб-службы из NodeJS Ошибка - PullRequest
0 голосов
/ 20 декабря 2018

Я пытаюсь вызвать Java Webservice API, используя библиотеку Node JS - SOAP.Однако я получаю ошибку собственности.Я уверен, что я использую какое-то неправильное свойство, но я не знаю, что использовать и как устранить неполадки.

Вот WSDL.

<?xml version="1.0" encoding="UTF-8"?>
<!-- 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 xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://jaxws.joshis1.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" 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>

Вот мой модуль узла -

 var soap = require('soap');
  var url = 'http://localhost:8888/webservice/helloworld?wsd';
  var args = {name: 'ABC'};
  soap.createClient(url, function(err, client) {
      client.sayHello(args, function(err, result) {
          console.log(result);
      });
  }); 

когда я запускаю узел test.js

test.js:5
      client.sayHello(args, function(err, result) {
             ^
TypeError: Cannot read property 'sayHello' of undefined

Я попытался python , чтобы понять, как это выглядит.

Вот службы

from pysimplesoap.client import SoapClient
WSDL_URL = 'http://localhost:8888/webservice/helloworld?wsdl'
client = SoapClient(wsdl=WSDL_URL, ns="web", trace=True)
list_of_services = [service for service in client.services]
#print(client.services)
method = client.services['webServiceImplService']['ports']['webServiceImplPort']
print(method)
method.sayHello('SJ')

Я все еще не уверен, как вызвать операцию сейчас.

{'location': 'http://localhost:8888/webservice/helloworld', 'soap_uri': 'http://schemas.xmlsoap.org/wsdl/soap/', 'service_name': 'webServiceImplService', 'operations': {'sayHello': {'fault_msgs': {}, 'faults': {}, 'action': '', 'namespace': 'http://jaxws.joshis1.com/', 'parameter_order': [''], 'documentation': 'None', 'header': {}, 'name': 'sayHello', 'qualified': False, 'input': {'sayHello': sayHello {arg0: str}}, 'style': None, 'output': {'sayHelloResponse': sayHelloResponse {return: str}}}}, 'transport': 'http://schemas.xmlsoap.org/soap/http', 'port_type_name': 'IwebServiceInterface', 'name': 'webServiceImplPortBinding', 'soap_ver': 'soap11', 'style': 'document'}
...