Giter Club home page Giter Club logo

Comments (4)

pfumagalli avatar pfumagalli commented on May 27, 2024

Flagging @esivkov to this one!

from wsdl-tsclient.

dderevjanik avatar dderevjanik commented on May 27, 2024

Hi,

wsdl-tsclient only inherits parsed types from node-soap and then generates client.... Some complex types are too "complex" :/ . Right now, there's no easy solution for this. I think it should be handled first by node-soap and then I can implement it in wsdl-tsclient

from wsdl-tsclient.

Hufschmidt avatar Hufschmidt commented on May 27, 2024

You can pass a customDeserializer into node-soap's createClientAsync method, maybe wsdl-tsclient could use this?

We do this for example to generate Date-Objects from a WSDL object containing custom Date & DateTime types, but those types are currently detected as simple strings by wsdl-tsclient.

On the reverse-direction you can pass custom-types as arguments into WSDL methods generated by node-soap as long as they provide a string $value property. There is currently no way to handle this mapping with wsdl-tsclient as well.


Example File: OrgUnitService.wsdl.txt

With example customDeserializer:

const client = soap.createClientAsync('example.wsdl', {
  customDeserializer:  {
    date: (text: string, xmlContext: XMLContext): SoapDate | string | undefined => {
      if (xmlContext.nil) { return undefined; }
      if (text.length > 0) { return new SoapDate(text); }
      return text;
    },
  }
});

And example custom type:

import moment from 'moment';

class SoapDate {
  protected $value: string;
  protected data: moment.Moment;

  public constructor(input: string | moment.Moment) {
    if (moment.isMoment(input)) {
      this.data = moment.utc(input, 'YYYY-MM-DD');
    } else {
     this.data = input;
    }
    this.$value = this.data.format('YYYY-MM-DD');
  }

This custom-type can be used as any string-type argument of a Soap-Method due to its $value property and with the customDeserializer it is returned by any Soap-Method that returns an argument of type date.

In my customized type-definitions I can ensure that Date-Type input and output values are pinned to the corresponding SoapDate-type, reducing any ambiguity when reading results or piping in arguments.

from wsdl-tsclient.

Hufschmidt avatar Hufschmidt commented on May 27, 2024

Addendum: This not only affects complex-types but (understandably) any customDeserializer type.

An option to pass in a custom type mapping from WSDL TypeDefinition to TypeScript type would be nice or as an alternative
an option to preserve the WSDL TypeDefinition name here instead of pinning it to string:

type: "string",

type: "string",

For example replace "string" with the type value.
This would preserve this information and allow for text-level post-processing and would be an easy workaround.

from wsdl-tsclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.