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.endpoint = '';
this.element_form_default = 'unqualified';
}
};

module.exports = WSDL;

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

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

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');

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 operation_tag = this._read_tag(binding_tag,'operation','http://schemas.xmlsoap.org/wsdl/');

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

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/');
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;
}
};

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

WSDL.prototype._read_namespaces = function(attrs) {
var self = this;
Expand All @@ -76,21 +76,21 @@ WSDL.prototype._read_namespaces = function(attrs) {
self.target_namespace = url;
}
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;
}
});
}
};

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

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

0 comments on commit ed55853

Please sign in to comment.