Skip to content

Commit

Permalink
fix for operations mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Howard Engelhart <howard@cinema6.com>
  • Loading branch information
howardengelhart committed Oct 1, 2014
1 parent c67a3b2 commit cfab932
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/soap-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ SOAPConnector.prototype._methodName = function (serviceName, portName, operation
for (var m in methods) {
var method = methods[m];
if (method.service === serviceName && method.port === portName &&
(method.operation = operationName ||
(method.operation === operationName ||
method.operation === undefined && m === operationName)) {
// Return the matched method name
return m;
Expand Down
55 changes: 55 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,61 @@ describe('soap connector', function () {
done();
});

});

describe('models with operations', function(){
var ds;
before(function (done) {
ds = loopback.createDataSource('soap',
{
connector: require('../index'),
wsdl: path.join(__dirname, 'wsdls/weather.wsdl'),
operations : {
weatherInfo: {
service : 'Weather',
port : 'WeatherSoap',
operation : 'GetWeatherInformation'
},
cityForecastByZIP: {
service : 'Weather',
port : 'WeatherSoap',
operation : 'GetCityForecastByZIP'
},
cityWeatherByZIP: {
service : 'Weather',
port : 'WeatherSoap',
operation : 'GetCityWeatherByZIP'
}
}
});
ds.on('connected', function () {
done();
});
});

it('should create mapped methods for operations', function (done) {
var WeatherService = ds.createModel('WeatherService', {});

// Operation mapped method names are defined
(typeof WeatherService.cityForecastByZIP).should.eql('function');
(typeof WeatherService.cityWeatherByZIP).should.eql('function');
(typeof WeatherService.weatherInfo).should.eql('function');

// Actual method names are defined
(typeof WeatherService.GetCityForecastByZIP).should.eql('function');
(typeof WeatherService.GetCityWeatherByZIP).should.eql('function');
(typeof WeatherService.GetWeatherInformation).should.eql('function');

// Full method names for SOAP 12 operations are not defined (operations method defs prevent these from being created)
(typeof WeatherService.Weather_WeatherSoap12_GetWeatherInformation).should.eql('undefined');
(typeof WeatherService.Weather_WeatherSoap12_GetCityForecastByZIP).should.eql('undefined');
(typeof WeatherService.Weather_WeatherSoap12_GetCityWeatherByZIP).should.eql('undefined');

done();
});



});
});

Expand Down

0 comments on commit cfab932

Please sign in to comment.