Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: serviceName and portName must correspond to port binding #1226

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,7 @@ export class Server extends EventEmitter {
const obj = this.wsdl.xmlToObject(input);
const body = obj.Body;
const headers = obj.Header;
let binding: BindingElement;
let methodName: string;
let serviceName: string;
let portName: string;
const includeTimestamp = obj.Header && obj.Header.Security && obj.Header.Security.Timestamp;
const authenticate = this.authenticate || function defaultAuthenticate() { return true; };

Expand All @@ -324,16 +321,15 @@ export class Server extends EventEmitter {
}

// use port.location and current url to find the right binding
binding = (() => {
const { binding, serviceName, portName } = (() => {
const services = this.wsdl.definitions.services;
let firstPort: IPort;
let name;
for (name in services) {
serviceName = name;
let firstServiceName: string;
let firstPortName: string;
for (const serviceName in services) {
const service = services[serviceName];
const ports = service.ports;
for (name in ports) {
portName = name;
for (const portName in ports) {
const port = ports[portName];
const portPathname = url.parse(port.location).pathname.replace(/\/$/, '');

Expand All @@ -342,16 +338,26 @@ export class Server extends EventEmitter {
}

if (portPathname === pathname) {
return port.binding;
return {
serviceName,
portName,
binding: port.binding,
};
}

// The port path is almost always wrong for generated WSDLs
if (!firstPort) {
firstServiceName = serviceName;
firstPortName = portName;
firstPort = port;
}
}
}
return !firstPort ? void 0 : firstPort.binding;
return {
serviceName: firstServiceName,
portName: firstPortName,
binding: firstPort?.binding,
};
})();

if (!binding) {
Expand Down
Loading