Dominic Sore
Dominic Sore

Reputation: 385

node-soap - Cannot read properties of undefined, reading 'elements'

I'm having trouble setting up a node-soap client. My code for setup looks like this:

class DreamloveAdapter extends Adapter {
  soapClient: soap.Client | null = null;

  constructor(id: string) {
    super(id);
  }

  initialize = async () => {
    if (!process.env.DREAMLOVE_WEBSERVICE_URL)
      throw new Error("Missing DREAMLOVE_WEBSERVICE_URL env variable");

    try {
      this.soapClient = await soap.createClientAsync(
        "https://store.dreamlove.es/webservices/orderservice_wsdl.php"
      );
    } catch (error) {
      console.error(error);
      throw new Error("Error initialising Dreamlove adapter");
    }
  };
};

Note that the soap client will use the environment variable for passing in the service address, hence the check.

Now, whenever I instantiate a new class and run the initialise method I get the following error:

TypeError: Cannot read properties of undefined (reading 'elements')
    at MessageElement.postProcess (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/elements.js:530:35)
    at OperationElement.postProcess (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/elements.js:776:21)
    at PortTypeElement.postProcess (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/elements.js:815:19)
    at BindingElement.postProcess (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/elements.js:858:22)
    at ServiceElement.postProcess (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/elements.js:928:29)
    at eval (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/index.js:84:44)
    at WSDL._processNextInclude (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/index.js:1089:20)
    at WSDL.processIncludes (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/index.js:140:14)
    at eval (webpack-internal:///(rsc)/./node_modules/soap/lib/wsdl/index.js:74:18)
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

I thought maybe it was an issue running node-soap within a Node v20 environment but after running the createClient method with a known working WSDL: http://www.dneonline.com/calculator.asmx?WSDL this code works just fine.

I wondered if it could be an issue with SSL or something but I've tried running the server with a self cert and still nothing.

I've reached out to the service devs and they don't know.

The problem is, there error isn't super descriptive so I'm wondering if anyone knows what could cause this?

My thinking is that the WSDL on their end is malformed but I don't know enough about soap/wsdl to confirm. The URL is: https://store.dreamlove.es/webservices/orderservice_wsdl.php in case anyone is curious.

Any help would be appreciated.

Upvotes: 1

Views: 476

Answers (0)

Related Questions