Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix exception 'Parameter 'url' must be a string, not object' #870

Merged
merged 5 commits into from Oct 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ Server.prototype._requestListener = function(req, res) {
}
res.end();
} else if (req.method === 'POST') {
if (typeof req.headers['content-type'] !== "undefined") {
res.setHeader('Content-Type', req.headers['content-type']);
} else {
res.setHeader('Content-Type', "application/xml");
}
if (typeof req.headers['content-type'] !== "undefined") {
res.setHeader('Content-Type', req.headers['content-type']);
} else {
res.setHeader('Content-Type', "application/xml");
}

//request body is already provided by an express middleware
//in this case unzipping should also be done by the express middleware itself
Expand Down
2 changes: 1 addition & 1 deletion lib/wsdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ WSDL.prototype._processNextInclude = function(includes, callback) {
if (!/^https?:/.test(self.uri) && !/^https?:/.test(include.location)) {
includePath = path.resolve(path.dirname(self.uri), include.location);
} else {
includePath = url.resolve(self.uri, include.location);
includePath = url.resolve(self.uri||'', include.location);
}

options = _.assign({}, this.options);
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
"compress": "^0.99.0",
"debug": "~0.7.4",
"ejs": "~2.3.4",
"finalhandler": "^0.5.0",
"lodash": "3.x.x",
"node-uuid": "~1.4.3",
"optional": "^0.1.3",
"request": ">=2.9.0",
"sax": ">=0.6",
"selectn": "^0.9.6",
"serve-static": "^1.11.1",
"strip-bom": "~0.3.1",
"xml-crypto": "~0.8.0"
},
Expand Down
76 changes: 76 additions & 0 deletions test/server-xsd-include-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"use strict";

var fs = require('fs'),
soap = require('..'),
http = require('http'),
assert = require('assert'),
events = require('events'),
finalHandler = require('finalhandler'),
serveStatic = require('serve-static');

var test = {};

test.service = {
StockQuoteService: {
StockQuotePort: {
GetLastTradePrice: function (args) {
if (args.tickerSymbol === 'trigger error') {
throw new Error('triggered server error');
} else {
return {price: 19.56};
}
}
}
}
};

describe('SOAP Server(XSD include)', function () {
before(function (done) {
fs.readFile(__dirname + '/wsdl/strict/stockquote-url.wsdl', 'utf8', function (err, data) {
assert.ok(!err);
test.wsdl = data;
done();
});
});

beforeEach(function (done) {
var serve = serveStatic("./test/wsdl/strict");
test.server = http.createServer(function (req, res) {
var done = finalHandler(req, res);
serve(req, res, done);
}).listen(51515, null, null, function () {
var pathOrOptions = '/stockquote-url';
test.soapServer = soap.listen(test.server, pathOrOptions, test.service, test.wsdl);

test.baseUrl = 'http://' + test.server.address().address + ':' + test.server.address().port;

if (test.server.address().address === '0.0.0.0' || test.server.address().address === '::') {
test.baseUrl = 'http://127.0.0.1:' + test.server.address().port;
}

assert.ok(test.soapServer);
done();
});
});

afterEach(function (done) {
test.server.close(function () {
test.server = null;
delete test.soapServer;
test.soapServer = null;
done();
});
});


it('should allow `http` in `schemaLocation` attribute in `xsd:include` tag', function (done) {
var url = __dirname + '/wsdl/strict/stockquote-url.wsdl';

soap.createClient(url, function (err, client) {
assert.ok(!err);
assert.ok(client);
done();
});
});

});
108 changes: 108 additions & 0 deletions test/wsdl/strict/stockquote-url.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0"?>

<wsdl:definitions name="StockQuote"
targetNamespace="http://example.com/stockquote.wsdl"
xmlns:tns="http://example.com/stockquote.wsdl"
xmlns:xsd1="http://example.com/stockquote.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:types>
<xsd:schema>
<xsd:include schemaLocation="http://localhost:51515/ImportSample.xsd"/>
</xsd:schema>


<xsd:schema targetNamespace="http://example.com/stockquote.xsd" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:element name="TradePriceRequest">
<xsd:complexType>
<xsd:all>
<xsd:element name="tickerSymbol" type="string"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="TradePrice">
<xsd:complexType>
<xsd:all>
<xsd:element name="price" type="float"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="TradePriceSubmit">
<xsd:complexType>
<xsd:all>
<xsd:element name="tickerSymbol" type="string"/>
<xsd:element name="price" type="float"/>
</xsd:all>
</xsd:complexType>
</xsd:element>
<xsd:element name="valid" type="boolean"/>
</xsd:schema>
</wsdl:types>

<wsdl:message name="GetLastTradePriceInput">
<wsdl:part name="body" element="xsd1:TradePriceRequest"/>
</wsdl:message>

<wsdl:message name="GetLastTradePriceOutput">
<wsdl:part name="body" element="xsd1:TradePrice"/>
</wsdl:message>

<wsdl:message name="SetTradePriceInput">
<wsdl:part name="body" element="xsd1:TradePriceSubmit"/>
</wsdl:message>

<wsdl:message name="IsValidPriceInput">
<wsdl:part name="body" element="xsd1:TradePrice"/>
</wsdl:message>

<wsdl:message name="IsValidPriceOutput">
<wsdl:part name="body" element="xsd1:valid"/>
</wsdl:message>

<wsdl:portType name="StockQuotePortType">
<wsdl:operation name="GetLastTradePrice">
<wsdl:input message="tns:GetLastTradePriceInput"/>
<wsdl:output message="tns:GetLastTradePriceOutput"/>
</wsdl:operation>
<wsdl:operation name="SetTradePrice">
<wsdl:input message="tns:SetTradePriceInput"/>
</wsdl:operation>
<wsdl:operation name="IsValidPrice">
<wsdl:input message="tns:IsValidPriceInput"/>
<wsdl:output message="tns:IsValidPriceOutput"/>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetLastTradePrice">
<soap:operation soapAction="http://example.com/GetLastTradePrice"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="SetTradePrice">
<soap:operation soapAction="http://example.com/SetTradePrice"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
<wsdl:operation name="IsValidPrice">
<soap:operation soapAction="http://example.com/IsValidPrice"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>

<wsdl:service name="StockQuoteService">
<wsdl:port name="StockQuotePort" binding="tns:StockQuoteSoapBinding">
<soap:address location="https://localhost:51515/stockquote"/>
</wsdl:port>
</wsdl:service>

</wsdl:definitions>