Add method describe to Client. (#13266)

This commit is contained in:
Leo Liang
2016-12-25 04:57:38 +09:00
committed by Masahiro Wakame
parent 94c44cad2e
commit 2157d75e67
2 changed files with 13 additions and 11 deletions
+1
View File
@@ -23,6 +23,7 @@ interface Client extends events.EventEmitter {
[method: string]: (args: any, fn: (err: any, result: any) => void, options?: any, extraHeaders?: any) => void;
addSoapHeader(headJSON: any): void;
setEndpoint(endpoint: string): void;
describe(): any;
}
export interface Server extends events.EventEmitter {
+12 -11
View File
@@ -8,9 +8,9 @@ const url = 'http://example.com/wsdl?wsdl';
const wsdlOptions = { name: 'value' };
soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) {
let securityOptions = { 'hasTimeStamp': false };
let securityOptions = { hasTimeStamp: false };
client.setSecurity(new soap.WSSecurity('user', 'password', securityOptions));
let defaults = {'rejectUnauthorized': false};
let defaults = {rejectUnauthorized: false};
client.setSecurity(new soap.ClientSSLSecurity('/path/to/key', '/path/to/cert', '/path/to/ca',defaults));
client.addSoapHeader({});
client.setEndpoint('http://localhost');
@@ -23,6 +23,7 @@ soap.createClient(url, wsdlOptions, function(err: any, client: soap.Client) {
client.on('request', function(obj: any) {
//obj is an object
});
client.describe();
});
var myService = {
@@ -33,23 +34,23 @@ var myService = {
name: args.name
};
},
// This is how to define an asynchronous function.
// This is how to define an asynchronous function.
MyAsyncFunction: function(args: any, callback: any) {
// do some work
// do some work
callback({
name: args.name
});
},
// This is how to receive incoming headers
// 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`
// 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 {
@@ -59,11 +60,11 @@ var myService = {
}
}
};
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);