Skip to content

Commit

Permalink
code pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Greenstock committed May 10, 2011
1 parent 78374d9 commit ed55853
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/douche/wsdl.js
Expand Up @@ -9,7 +9,7 @@ var WSDL = function(href) {
this.operations = {}; this.operations = {};
this.endpoint = ''; this.endpoint = '';
this.element_form_default = 'unqualified'; this.element_form_default = 'unqualified';
} };


module.exports = WSDL; module.exports = WSDL;


Expand All @@ -21,40 +21,40 @@ WSDL.prototype.parse = function(cb) {
self._read_xml(xml); self._read_xml(xml);
cb(self); cb(self);
}); });
} };


WSDL.prototype._read_xml = function(attrs) { WSDL.prototype._read_xml = function(attrs) {
var self = this; var self = this;


var types_tag = this._read_tag(attrs,'types','http://schemas.xmlsoap.org/wsdl/'); var types_tag = this._read_tag(attrs,'types','http://schemas.xmlsoap.org/wsdl/');
var schema_tag = this._read_tag(types_tag,'schema','http://www.w3.org/2001/XMLSchema'); var schema_tag = this._read_tag(types_tag,'schema','http://www.w3.org/2001/XMLSchema');


this.element_form_default = schema_tag['@']['elementFormDefault'] || this.element_form_default; this.element_form_default = schema_tag['@'].elementFormDefault || this.element_form_default;


var binding_tag = this._read_tag(attrs,'binding','http://schemas.xmlsoap.org/wsdl/'); var binding_tag = this._read_tag(attrs,'binding','http://schemas.xmlsoap.org/wsdl/');
var operation_tag = this._read_tag(binding_tag,'operation','http://schemas.xmlsoap.org/wsdl/'); var operation_tag = this._read_tag(binding_tag,'operation','http://schemas.xmlsoap.org/wsdl/');


if(operation_tag instanceof Array) { if(operation_tag instanceof Array) {
operation_tag.forEach(function(operation_tag,index) { operation_tag.forEach(function(operation_tag,index) {
var name = operation_tag['@']['name']; var name = operation_tag['@'].name;
var soap_action = self._read_tag(operation_tag,'operation','http://schemas.xmlsoap.org/wsdl/soap/')['@']['soapAction']; var soap_action = self._read_tag(operation_tag,'operation','http://schemas.xmlsoap.org/wsdl/soap/')['@'].soapAction;
self.operations[name] = { self.operations[name] = {
soap_action: soap_action soap_action: soap_action
}; };
}); });
} else { } else {
var name = operation_tag['@']['name']; var name = operation_tag['@'].name;
var soap_action = self._read_tag(operation_tag,'operation','http://schemas.xmlsoap.org/wsdl/soap/')['@']['soapAction']; var soap_action = self._read_tag(operation_tag,'operation','http://schemas.xmlsoap.org/wsdl/soap/')['@'].soapAction;
self.operations[name] = { self.operations[name] = {
soap_action: soap_action soap_action: soap_action
}; };
} }


var service_tag = this._read_tag(attrs,'service','http://schemas.xmlsoap.org/wsdl/'); var service_tag = this._read_tag(attrs,'service','http://schemas.xmlsoap.org/wsdl/');
var port_tag = this._read_tag(service_tag,'port','http://schemas.xmlsoap.org/wsdl/'); var port_tag = this._read_tag(service_tag,'port','http://schemas.xmlsoap.org/wsdl/');
this.endpoint = this._read_tag(port_tag,'address','http://schemas.xmlsoap.org/wsdl/soap/')['@']['location']; this.endpoint = this._read_tag(port_tag,'address','http://schemas.xmlsoap.org/wsdl/soap/')['@'].location;
return; return;
} };


WSDL.prototype._read_tag = function(attrs,tag_name,namespace) { WSDL.prototype._read_tag = function(attrs,tag_name,namespace) {
for(var prefix in this.namespaces) { for(var prefix in this.namespaces) {
Expand All @@ -67,7 +67,7 @@ WSDL.prototype._read_tag = function(attrs,tag_name,namespace) {
} }
} }
return false; return false;
} };


WSDL.prototype._read_namespaces = function(attrs) { WSDL.prototype._read_namespaces = function(attrs) {
var self = this; var self = this;
Expand All @@ -76,21 +76,21 @@ WSDL.prototype._read_namespaces = function(attrs) {
self.target_namespace = url; self.target_namespace = url;
} }
if(index == 'xmlns') { if(index == 'xmlns') {
self.namespaces['_xmlns'] = url; self.namespaces._xmlns = url;
} }
if(index.indexOf('xmlns:') == 0) { if(index.indexOf('xmlns:') === 0) {
self.namespaces[index.split(':')[1]] = url; self.namespaces[index.split(':')[1]] = url;
} }
}); });
} };


WSDL.prototype._get = function(cb) { WSDL.prototype._get = function(cb) {
var url_parts = url.parse(this.href); var url_parts = url.parse(this.href);


http.get({ http.get({
host: url_parts.host, host: url_parts.host,
port: url_parts.port || 80, port: url_parts.port || 80,
path: (url_parts.pathname || '/') + (url_parts.search || ''), path: (url_parts.pathname || '/') + (url_parts.search || '')
}, function(res) { }, function(res) {
var xml = ''; var xml = '';
res.setEncoding('utf8'); res.setEncoding('utf8');
Expand All @@ -104,4 +104,4 @@ WSDL.prototype._get = function(cb) {
}).on('error', function(err) { }).on('error', function(err) {
cb(err,null); cb(err,null);
}); });
} };

0 comments on commit ed55853

Please sign in to comment.