Update soap.d.ts (#8709)

* soap Server

* Fix definitions
This commit is contained in:
CageFox
2016-05-12 07:58:19 +03:00
committed by Horiuchi_H
parent b0684b27a4
commit dcafb59ee7
2 changed files with 55 additions and 3 deletions

View File

@@ -2,6 +2,8 @@
import * as soap from 'soap';
import * as events from 'events';
import * as fs from "fs";
import * as http from "http";
const url = 'http://example.com/wsdl?wsdl';
const wsdlOptions = { name: 'value' };
@@ -21,3 +23,45 @@ soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) {
});
});
var myService = {
MyService: {
MyPort: {
MyFunction: function(args: any) {
return {
name: args.name
};
},
// This is how to define an asynchronous function.
MyAsyncFunction: function(args: any, callback: any) {
// do some work
callback({
name: args.name
});
},
// This is how to receive incoming headers
HeadersAwareFunction: function(args: any, cb: any, headers: any) {
return {
name: headers.Token
};
},
// You can also inspect the original `req`
reallyDeatailedFunction: function(args: any, cb: any, headers: any, req: any) {
console.log('SOAP `reallyDeatailedFunction` request from ' + req.connection.remoteAddress);
return {
name: headers.Token
};
}
}
}
};
var xml = fs.readFileSync('myservice.wsdl', 'utf8'),
server = http.createServer(function(request,response) {
response.end("404: Not Found: " + request.url);
});
server.listen(8000);
soap.listen(server, '/wsdl', myService, xml);

14
soap/soap.d.ts vendored
View File

@@ -1,9 +1,9 @@
// Type definitions for soap
// Project: https://www.npmjs.com/package/soap
// Definitions by: Nicole Wang <https://github.com/nicoleWjie>
// Definitions by: Nicole Wang <https://github.com/nicoleWjie>, Cage Fox <https://github.com/cagefox>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path='../node/node.d.ts' />
/// <reference path="../node/node.d.ts" />
declare module 'soap' {
import * as events from 'events';
@@ -18,4 +18,12 @@ declare module 'soap' {
}
function createClient(wsdlPath: string, options: any, fn: (err: any, client: Client) => void): void;
}
export interface Server extends events.EventEmitter {
addSoapHeader(soapHeader: any, name:any, namespace: any, xmlns: any): any;
changeSoapHeader(index: any, soapHeader: any, name: any, namespace: any, xmlns: any): any;
getSoapHeaders(): any;
clearSoapHeaders(): any;
log(type: any, data: any): any;
}
export function listen(server: any, path: string, service:any, wsdl: string): Server;
}