Comparing version 0.0.27 to 0.0.28
@@ -25,5 +25,2 @@ /* | ||
RawConverter.prototype.pack = function (config, data) { | ||
if (!Buffer.isBuffer(data)){ | ||
throw new Error('data should be a buffer'); | ||
} | ||
return data; | ||
@@ -30,0 +27,0 @@ }; |
@@ -261,3 +261,3 @@ /* | ||
info.errmsg = err.message; | ||
logger.warning('request failed ' + ralUtil.qs(info)); | ||
logger.fatal('request failed ' + ralUtil.qs(info)); | ||
process.nextTick(function(){ | ||
@@ -264,0 +264,0 @@ me.emit('error', err); |
{ | ||
"name": "node-ral", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"description": "a rpc client for node", | ||
@@ -33,2 +33,3 @@ "main": "index.js", | ||
"request": "2.40.0", | ||
"soap": "^0.6.1", | ||
"underscore": "1.6.0", | ||
@@ -35,0 +36,0 @@ "urlencode": "0.2.0", |
@@ -108,1 +108,3 @@ node-ral | ||
- [X] HTTP | ||
- [X] SOAP | ||
@@ -340,3 +340,3 @@ /* | ||
it('pack should change headers and query', function () { | ||
it('pack should change query', function () { | ||
var converter = new QueryStringConverter(); | ||
@@ -348,3 +348,2 @@ var data = { | ||
converter.pack(mockUTF8Context, data); | ||
mockUTF8Context.headers['Content-Type'].should.be.eql('application/json'); | ||
mockUTF8Context.query.should.be.eql(data); | ||
@@ -384,8 +383,2 @@ }); | ||
}); | ||
it('should only accept buffer data', function () { | ||
var converter = new RawConverter(); | ||
var data = "fake buffer"; | ||
(function(){converter.pack({}, data)}).should.be.throwError(/data should be a buffer/); | ||
}); | ||
}); | ||
@@ -392,0 +385,0 @@ |
@@ -11,2 +11,3 @@ /* | ||
var HttpProtocol = require('../lib/ext/protocol/httpProtocol.js'); | ||
var SoapProtocol = require('../lib/ext/protocol/soapProtocol.js'); | ||
var util = require('../lib/util.js'); | ||
@@ -251,2 +252,40 @@ | ||
}); | ||
}); | ||
describe('soap protocol', function () { | ||
it('should request wsdl service successfully', function (done) { | ||
var soap_test = require('./protocol/soap_protocol.js'); | ||
var context = SoapProtocol.normalizeConfig(soap_test); | ||
context.method = 'GetWeather'; | ||
context.payload = { | ||
CityName: 'Beijing', | ||
CountryName: 'China' | ||
}; | ||
var soapProtocol = new SoapProtocol(); | ||
soapProtocol.talk(context, function(res){ | ||
res.on('data', function(data){ | ||
data.GetWeatherResult.should.be.ok; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should request wsdl service with service.port successfully', function (done) { | ||
var soap_test = require('./protocol/soap_protocol.js'); | ||
var context = SoapProtocol.normalizeConfig(soap_test); | ||
context.soapService = 'GlobalWeather'; | ||
context.soapPort = 'GlobalWeatherSoap12'; | ||
context.method = 'GetWeather'; | ||
context.payload = { | ||
CityName: 'Beijing', | ||
CountryName: 'China' | ||
}; | ||
var soapProtocol = new SoapProtocol(); | ||
soapProtocol.talk(context, function(res){ | ||
res.on('data', function(data){ | ||
data.GetWeatherResult.should.be.ok; | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -301,2 +301,37 @@ /* | ||
}); | ||
it('should work fine with soap', function(done) { | ||
before(function( ok ){ | ||
isInited.on('done', ok); | ||
}); | ||
var req = RAL('SOAP', { | ||
method: 'GetWeather', | ||
data: { | ||
CityName: 'Beijing', | ||
CountryName: 'China' | ||
} | ||
}); | ||
req.on('data', function(data){ | ||
data.GetWeatherResult.should.be.ok; | ||
done(); | ||
}); | ||
}); | ||
it('should work fine with soap timeout', function(done) { | ||
before(function( ok ){ | ||
isInited.on('done', ok); | ||
}); | ||
var req = RAL('SOAP', { | ||
method: 'GetWeather', | ||
timeout: 1, | ||
data: { | ||
CityName: 'Beijing', | ||
CountryName: 'China' | ||
} | ||
}); | ||
req.on('error', function(err){ | ||
err.message.should.be.match(/request time out/); | ||
done(); | ||
}); | ||
}); | ||
}); |
265162
64
7261
110
9
+ Addedsoap@^0.6.1
+ Addedfirst-chunk-stream@0.1.0(transitive)
+ Addedis-utf8@0.2.1(transitive)
+ Addedlodash@2.4.2(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsoap@0.6.1(transitive)
+ Addedstrip-bom@0.3.1(transitive)