got oscarhost soap api to work
This commit is contained in:
parent
9c6fb5df87
commit
c6b5cad9bf
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,6 @@
|
|||||||
Oscar_Credentials.md
|
docs/Oscar_Credentials.md
|
||||||
|
scripts/test_oscarhost.js
|
||||||
|
scripts/oscarhost/private/
|
||||||
|
|
||||||
# iOS / Apple
|
# iOS / Apple
|
||||||
# ===========
|
# ===========
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
"postinstall": "bower install --config.interactive=false; grunt build"
|
"postinstall": "bower install --config.interactive=false; grunt build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^1.4.0",
|
"async": "^1.4.2",
|
||||||
"body-parser": "~1.9.0",
|
"body-parser": "~1.9.0",
|
||||||
"bower": "~1.3.8",
|
"bower": "~1.3.8",
|
||||||
"chalk": "~1.0.0",
|
"chalk": "~1.0.0",
|
||||||
@ -78,6 +78,8 @@
|
|||||||
"passport-local": "~1.0.0",
|
"passport-local": "~1.0.0",
|
||||||
"passport-twitter": "~1.0.2",
|
"passport-twitter": "~1.0.2",
|
||||||
"raven": "^0.8.1",
|
"raven": "^0.8.1",
|
||||||
|
"request": "^2.60.0",
|
||||||
|
"request-promise": "^0.4.3",
|
||||||
"satelize": "~0.1.1",
|
"satelize": "~0.1.1",
|
||||||
"should": "~4.1.0",
|
"should": "~4.1.0",
|
||||||
"supertest": "~0.14.0",
|
"supertest": "~0.14.0",
|
||||||
|
|||||||
23
scripts/oscarhost/OscarSecurity.js
Normal file
23
scripts/oscarhost/OscarSecurity.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var crypto = require('crypto'),
|
||||||
|
passwordDigest = require('soap/lib/utils').passwordDigest;
|
||||||
|
|
||||||
|
function WSSecurity(username, password) {
|
||||||
|
this._username = username;
|
||||||
|
this._password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
WSSecurity.prototype.toXML = function() {
|
||||||
|
var password = "<wsse:Password Type=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText\">" + this._password + "</wsse:Password>";
|
||||||
|
|
||||||
|
return "<wsse:Security xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" soap:mustUnderstand=\"1\">" +
|
||||||
|
"<wsse:UsernameToken xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" wsu:Id=\"UsernameToken-1\">" +
|
||||||
|
"<wsse:Username>" + this._username + "</wsse:Username>" +
|
||||||
|
password +
|
||||||
|
"</wsse:UsernameToken>" +
|
||||||
|
"</wsse:Security>";
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = WSSecurity;
|
||||||
52
scripts/oscarhost/test_oscarhost.js
Normal file
52
scripts/oscarhost/test_oscarhost.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
var soap = require('soap'),
|
||||||
|
request = require('request'),
|
||||||
|
async = require('async'),
|
||||||
|
OscarSecurity = require('./OscarSecurity');
|
||||||
|
|
||||||
|
|
||||||
|
var url_login = 'http://someurl.com/ws?wsdl',
|
||||||
|
url_demo = 'http://someurl.com/ws?wsdl',
|
||||||
|
args_demo = {arg0: 12351235},
|
||||||
|
args_login = {arg0: 'mylogin', arg1: 'mypassword'};
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
ignoredNamespaces: {
|
||||||
|
namespaces: ['targetNamespace', 'typedNamespace'],
|
||||||
|
override: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async.waterfall([
|
||||||
|
function (callback) {
|
||||||
|
soap.createClient(url_login, options, function(err, client) {
|
||||||
|
client.login(args_login, function (err, result) {
|
||||||
|
if(err) callback(err);
|
||||||
|
callback(null, result.return);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function (security_obj, callback) {
|
||||||
|
|
||||||
|
console.log(security_obj);
|
||||||
|
|
||||||
|
soap.createClient(url_demo, options, function(err, client) {
|
||||||
|
client.setSecurity(new OscarSecurity(security_obj.securityId, security_obj.securityTokenKey) );
|
||||||
|
|
||||||
|
client.getDemographic(args_demo, function (err, result) {
|
||||||
|
if(err) callback(err);
|
||||||
|
console.log(result);
|
||||||
|
callback(null, 'DemographicService');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], function(err, result) {
|
||||||
|
if(err) throw err;
|
||||||
|
|
||||||
|
console.log(result);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user