Comments (4)
Flagging @esivkov to this one!
from wsdl-tsclient.
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.
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.
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
:
Line 158 in 60d1eda
Line 98 in 60d1eda
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)
- [Question] Using the client in Angular
- wsdl_options not available in the generated interface methods HOT 2
- `wsdl_headers` not being passed to request HOT 1
- Filename globbing is not working
- Missing support for xs:group type?
- node-soap parsed primitive types do not match HOT 2
- Can't generate a <fieldName xsi:nil="true" /> field in request payload
- Inserting syntax kind of ExportDeclaration, but ExpressionStatement was inserted. HOT 1
- Update to soap ^1.0.0
- Way to do pre action before sending soap request HOT 1
- Skip folder name on destination dir
- error TS2440: Import declaration conflicts with local declaration of 'SoapClient'. HOT 2
- Use type names instead of attribute names for types
- Need help to get started HOT 1
- Emit definitions of unused interfaces
- wsdl-tsclient includes dev dependencies HOT 1
- Running into an issue with OpenBraceToken child on valid wsdl HOT 3
- Attributes not generated HOT 1
- Generated Index Errors
- Ordering of elements in XSD Sequence not honoured
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wsdl-tsclient.