-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support *Async methods for soap client #11
Labels
Comments
I made an example at https://github.com/ReeganExE/node-soap-example/blob/master/src/index.ts Generate typesnpm run wsdl -- 'http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl' Output at src/IP2Geo/IP2GeoSoap.d.tswill look like this: export interface IIP2GeoSoapSoap extends Client {
ResolveIP: (input: Partial<IResolveIPInput>, cb: (err: any | null, result: IResolveIPOutput, rawResult: string, soapHeader: {[k: string]: any; }, rawRequest: string) => any, options?: any, extraHeaders?: any) => void;
ResolveIPAsync: (input: Partial<IResolveIPInput>, options?: any, extraHeaders?: any) => Promise<[IResolveIPOutput, string, {[k: string]: any; }, string]>;
} Test the outputimport { createClientAsync, Client } from 'soap';
// import types from the generated source
import { IIP2GeoSoapSoap } from './IP2Geo/IP2GeoSoap';
function createSoapClientAs<T extends Client>(url: string): Promise<T> {
return createClientAsync(url) as Promise<T>;
}
async function main() {
const url = 'http://ws.cdyne.com/ip2geo/ip2geo.asmx?wsdl';
const client = await createSoapClientAs<IIP2GeoSoapSoap>(url);
try {
const [result] = await client.ResolveIPAsync({ ipAddress: '1.1.1.1', licenseKey: '' });
console.log(result.ResolveIPResult);
} catch (error) {
console.log(error);
}
}
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
soap
library adds methods that return a promise. By default this are suffixed with Async, though that is customizable (in case it conflicts with a method).E.g.
The text was updated successfully, but these errors were encountered: