create soap client in typescript from wsdl

Viewed 3005

I am using this library https://www.npmjs.com/package/soap to generate a client from a wsdl and more particulary the line soap.createclient(url).

The problem with that is that the url must correspond to a wsdl file delivered by a webserver, in my case, I can't do that.

So I wanted to download the wsdl file, store it in my project, and give it to the createclient method either by giving all the content in a string parameter or by giving the like of the downloaded file (I am using webpack fyi), but none of these options are working, which seems strange, as it's written in the documentation that the createclient method seems to support local filesystem path.

Thanks in advance for your help

1 Answers

I'm assuming this is roughly your folder structure and you're running the app from the root:

/dist
  |- app.js
/src
  |- app.ts
  |- soap.wsdl

In that case the url for the .wsdl file needs to be './src/soap.wsdl' for it to work and you need to ship the src folder along with the dist folder.

If you're only shipping the dist folder you need to include the .wsdl file in the dist folder and specify the url as './dist/soap.wsdl'. If you delete the dist folder on each build, you need to make sure the .wsdl file is copied there in the build.

Another option is to add an assets folder in the root, put the .wsdl file in there, point to it by using './assets/soap.wsdl' and shipping the assets folder with the dist folder.

Related