node.js - Simple webservice with node-soap -


i trying implement simple web service using soap using node js , node-soap, client side seems have problems using server.

assert.js:92   throw new assert.assertionerror({         ^ assertionerror: invalid message definition document style binding 

my wsdl file is:

<?xml version="1.0" encoding="utf-8"?> <wsdl:definitions name="wscalc1"                   targetnamespace="http://localhost:8000/wscalc1"                   xmlns="http://localhost:8000/wscalc1"                   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"                   xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"                   xmlns:xs="http://www.w3.org/2001/xmlschema"                   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">    <wsdl:message name="sumarrequest">     <wsdl:part name="a" type="xs:string"></wsdl:part>     <wsdl:part name="b" type="xs:string"></wsdl:part>   </wsdl:message>    <wsdl:message name="multiplicarrequest">     <wsdl:part name="a" type="xs:string"></wsdl:part>     <wsdl:part name="b" type="xs:string"></wsdl:part>   </wsdl:message>    <wsdl:message name="multiplicarresponse">     <wsdl:part name="res" type="xs:string"></wsdl:part>   </wsdl:message>    <wsdl:message name="sumarresponse">     <wsdl:part name="res" type="xs:string"></wsdl:part>   </wsdl:message>     <wsdl:porttype name="calcp">     <wsdl:operation name="sumar">       <wsdl:input message="sumarrequest"></wsdl:input>       <wsdl:output message="sumarresponse"></wsdl:output>     </wsdl:operation>      <wsdl:operation name="multiplicar">       <wsdl:input message="multiplicarrequest"></wsdl:input>       <wsdl:output message="multiplicarresponse"></wsdl:output>     </wsdl:operation>   </wsdl:porttype>    <wsdl:binding name="calcb" type="calcp">     <soap:binding style="document"                    transport="http://schemas.xmlsoap.org/soap/http"/>      <wsdl:operation name="sumar">       <soap:operation soapaction="sumar"/>       <wsdl:input>         <soap:body use="literal"                     encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"/>       </wsdl:input>       <wsdl:output>         <soap:body use="literal"                     encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"/>       </wsdl:output>     </wsdl:operation>      <wsdl:operation name="multiplicar">       <soap:operation soapaction="multiplicar"/>       <wsdl:input>         <soap:body use="literal"                     encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"/>       </wsdl:input>       <wsdl:output>         <soap:body use="literal"                     encodingstyle="http://schemas.xmlsoap.org/soap/encoding/"/>       </wsdl:output>     </wsdl:operation>   </wsdl:binding>    <wsdl:service name="ws">     <wsdl:port name="calc" binding="calcb">       <soap:address location="http://localhost:8000/wscalc1"/>     </wsdl:port>   </wsdl:service> </wsdl:definitions> 

server.js

var soap = require('soap'); var http = require('http');  var service = {     ws: {         calc: {             sumar : function(args) {                 var n = args.a + args.b;                 return { res : n };             },              multiplicar : function(args) {                 var n = args.a * args.b;                 return { res : n }             }         }     } }  var xml = require('fs').readfilesync('wscalc1.wsdl', 'utf8'),  server = http.createserver(function(request,response) {     response.end("404: not found: "+request.url) });  server.listen(8000); soap.listen(server, '/wscalc1', service, xml); 

client.js

var soap = require('soap'); var url = 'http://localhost:8000/wscalc1?wsdl'; soap.createclient(url, function(err, client) {      if (err) throw err;       console.log(client.describe().ws.calc);      client.multiplicar({"a":"1","b":"2"},function(err,res){         if (err) throw err;          console.log(res);     }); }); 

with code output is:

{ sumar:     { input: { a1: 'request', b1: 'request' },      output: { res: 'response' } },   multiplicar:     { input: { a2: 'request', b2: 'request' },      output: { res: 'response' } } }  assert.js:92   throw new assert.assertionerror({         ^ assertionerror: invalid message definition document style binding 

any appreciated

in wsdl file change style document rpc trying antoher response using client.js

what receive output.

{ sumar:     { input: { a: 'xs:string', b: 'xs:string' },      output: { res: 'xs:string' } },   multiplicar:     { input: { a: 'xs:string', b: 'xs:string' },      output: { res: 'xs:string' } } } { res: '2' } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -