node-soap icon indicating copy to clipboard operation
node-soap copied to clipboard

Feature: override host

Open homersimpsons opened this issue 2 months ago • 4 comments

Problem

Some SOAP api have a staging and a production domain. They sometimes provide only the production wsdl files and hence the developper is responsible to manually change the domain to the correct environment.

Context

The documentation says: https://github.com/vpulim/node-soap/blob/09a31e42dac15642f0a0433f5f128ac60ff12220/Readme.md?plain=1#L100

But this looks incorrect as it seems to override the full endpoint (including the URI part)

It is possible to override the httpClient but doing so is not really convenient

Suggested feature

Add a domain option or a urlHandler that would allow overriding the domain (or the full url, for example, to add a /staging prefix to the uri). The developer would then be able to use this to easily switch between environments.

I'm interested to try to contribute to this change.

homersimpsons avatar Oct 10 '25 16:10 homersimpsons

@homersimpsons -- feel free to propose a PR with the suggested change along with the tests check for set, unset, null, or invalid domain option. Need to handle cases when both endpoint and domainare specified and are in conflict with one another as well. The proposal otherwise makes sense. @w666 would review the PR for approval and merge.

smokhov avatar Oct 11 '25 03:10 smokhov

HI @homersimpsons.

I think you want this https://github.com/vpulim/node-soap?tab=readme-ov-file#clientsetendpointurl---overwrite-the-soap-service-endpoint-address

w666 avatar Oct 17 '25 19:10 w666

I think you want this https://github.com/vpulim/node-soap?tab=readme-ov-file#clientsetendpointurl---overwrite-the-soap-service-endpoint-address

Yes, that's what we are doing currently, but it forces us to hardcode (with a variable domain) every endpoint. If they ever changes we will have to update those part of the code (the service we use has one endpoint per service.

homersimpsons avatar Oct 21 '25 20:10 homersimpsons

What is the difference between overriding full URL or just a domain bit from the URL? You already have to keep them somewhere and conditionally update.

But if this is important for you just create a PR with some tests.

w666 avatar Oct 25 '25 19:10 w666