Skip to content

Commit 2b39cf4

Browse files
committed
WIP: Add multi service wsdl and template for a test
1 parent 3fd8ac6 commit 2b39cf4

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

test/server-service-bind-test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const soap = require('..');
2+
const http = require('http');
3+
const fs = require('fs');
4+
const path = require('path');
5+
const assert = require('assert');
6+
7+
const wsdl = fs.readFileSync(__dirname + '/wsdl/multi-service.wsdl', 'utf-8');
8+
9+
describe('SOAP Server Binding Resolution', function () {
10+
let server;
11+
12+
const serviceImpl = {
13+
Hello_Service: {
14+
Hello_Port: {
15+
sayHello: function (args) {
16+
return {
17+
greeting: args.firstName
18+
};
19+
}
20+
}
21+
},
22+
Hello_Service2: {
23+
Hello_Port2: {
24+
sayHello2: function (args) {
25+
return {
26+
greeting: args.firstName
27+
};
28+
}
29+
}
30+
}
31+
};
32+
33+
this.beforeAll(async function () {
34+
35+
server = http.createServer(function (req, res) {
36+
res.writeHead(200, { "Content-Type": "text/plain" });
37+
res.write("Hello");
38+
res.end();
39+
});
40+
41+
server.listen(8001, function () {
42+
soap.listen(server, '/SayHello', serviceImpl, wsdl);
43+
});
44+
});
45+
46+
this.afterAll(function () {
47+
server.close();
48+
});
49+
50+
it('should correctly resolve serviceName, portName, and binding', async function () {
51+
const client = await soap.createClientAsync(wsdl)
52+
assert.ok(client);
53+
console.log('client created:', client.describe());
54+
55+
// code below triggers "TypeError: Cannot read properties of undefined (reading 'description')
56+
// try {
57+
// const response = await client.sayHelloAsync({ firstName: 'Bob' });
58+
// console.log(`>>> response`, response[0])
59+
// } catch (err) {
60+
// console.error(`error`, err)
61+
// }
62+
});
63+
});

test/wsdl/multi-service.wsdl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions name="HelloService"
3+
targetNamespace="http://www.examples.com/wsdl/HelloService.wsdl"
4+
xmlns="http://schemas.xmlsoap.org/wsdl/"
5+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
6+
xmlns:tns="http://www.examples.com/wsdl/HelloService.wsdl"
7+
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
8+
9+
<message name="SayHelloRequest">
10+
<part name="firstName" type="xsd:string" />
11+
</message>
12+
<message name="SayHelloResponse">
13+
<part name="greeting" type="xsd:string" />
14+
</message>
15+
16+
<message name="SayByeRequest">
17+
<part name="firstName" type="xsd:string" />
18+
</message>
19+
<message name="SayByeResponse">
20+
<part name="message" type="xsd:string" />
21+
</message>
22+
23+
<portType name="Bye_PortType">
24+
<operation name="sayBye">
25+
<input message="tns:SayByeRequest" />
26+
<output message="tns:SayByeResponse" />
27+
</operation>
28+
</portType>
29+
<portType name="Hello_PortType">
30+
<operation name="sayHello">
31+
<input message="tns:SayHelloRequest" />
32+
<output message="tns:SayHelloResponse" />
33+
</operation>
34+
</portType>
35+
36+
<binding name="Hello_Binding" type="tns:Hello_PortType">
37+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
38+
<operation name="sayHello">
39+
<soap:operation soapAction="sayHello" />
40+
<input>
41+
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
42+
namespace="urn:examples:helloservice" use="encoded" />
43+
</input>
44+
<output>
45+
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
46+
namespace="urn:examples:helloservice" use="encoded" />
47+
</output>
48+
</operation>
49+
</binding>
50+
<binding name="Bye_Binding" type="tns:Bye_PortType">
51+
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
52+
<operation name="sayBye">
53+
<soap:operation soapAction="sayBye" />
54+
<input>
55+
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
56+
namespace="urn:examples:byeservice" use="encoded" />
57+
</input>
58+
<output>
59+
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
60+
namespace="urn:examples:byeservice" use="encoded" />
61+
</output>
62+
</operation>
63+
</binding>
64+
<service name="Hello_Service">
65+
<documentation>WSDL File for HelloService</documentation>
66+
<port binding="tns:Hello_Binding" name="Hello_Port">
67+
<soap:address location="http://localhost:8001/SayHello/" />
68+
</port>
69+
</service>
70+
<service name="Bye_Service">
71+
<documentation>WSDL File for HelloService</documentation>
72+
<port binding="tns:Bye_Binding" name="Bye_Port">
73+
<soap:address location="http://localhost:8001/SayBye/" />
74+
</port>
75+
</service>
76+
</definitions>

0 commit comments

Comments
 (0)