mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-30 17:04:20 +08:00
@@ -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
14
soap/soap.d.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user