forked from vpulim/node-soap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request vpulim#243 from godaddy/parse-response-operation-e…
…nding-with-out Fixing undefined value for json in client method when message names end with Out or Output.
- Loading branch information
Showing
18 changed files
with
259 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"use strict"; | ||
|
||
var assert = require('assert'); | ||
var fs = require('fs'); | ||
var glob = require('glob'); | ||
var http = require('http'); | ||
var path = require('path'); | ||
var soap = require('../'); | ||
var server; | ||
var port; | ||
var endpoint; | ||
var tests = glob.sync('./request-response-samples/*', {cwd:__dirname}) | ||
.map(function(node){return path.resolve(__dirname, node);}) | ||
.filter(function(node){return fs.statSync(node).isDirectory();}); | ||
var suite = {}; | ||
|
||
var requestContext = { | ||
//set these two within each test | ||
expectedRequest:null, | ||
responseToSend:null, | ||
requestHandler:function(req, res){ | ||
var chunks = []; | ||
req.on('data', function(chunk){ | ||
chunks.push(chunk); | ||
}); | ||
req.on('end', function(){ | ||
assert.equal(chunks.join(''), requestContext.expectedRequest); | ||
res.end(requestContext.responseToSend); | ||
requestContext.expectedRequest = null; | ||
requestContext.responseToSend = null; | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
before:function(done){ | ||
server = http.createServer(requestContext.requestHandler); | ||
server.listen(0, function(e){ | ||
if(e)return done(e); | ||
port = server.address().port; | ||
done(); | ||
}); | ||
}, | ||
after:function(){ | ||
server.close(); | ||
}, | ||
'Request Response Sampling':suite | ||
}; | ||
|
||
tests.forEach(function(test){ | ||
var name = path.basename(test); | ||
var wsdl = path.resolve(test, 'soap.wsdl'); | ||
var requestJSON = require(path.resolve(test, 'request.json')); | ||
var requestXML = ""+fs.readFileSync(path.resolve(test, 'request.xml')); | ||
var responseJSON = require(path.resolve(test, 'response.json')); | ||
var responseXML = ""+fs.readFileSync(path.resolve(test, 'response.xml')); | ||
|
||
generateTest(name, wsdl, requestXML, requestJSON, responseXML, responseJSON); | ||
}); | ||
|
||
function generateTest(name, wsdlPath, requestXML, requestJSON, responseXML, responseJSON){ | ||
suite[name] = function(done){ | ||
requestContext.expectedRequest = requestXML; | ||
requestContext.responseToSend = responseXML; | ||
soap.createClient(wsdlPath, function(err, client){ | ||
client.Message(requestJSON, function(err, json, body){ | ||
assert.deepEqual(json, responseJSON); | ||
assert.deepEqual(body, responseXML); | ||
done(); | ||
}); | ||
}, 'http://localhost:'+port+'/Message/Message.dll?Handler=Default'); | ||
}; | ||
} |
3 changes: 3 additions & 0 deletions
3
test/request-response-samples/Messages_suffixed_with__In_Out/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"bstrResourceId": "034b7ea5-8a04-11e3-9710-0050569575d8" | ||
} |
1 change: 1 addition & 0 deletions
1
test/request-response-samples/Messages_suffixed_with__In_Out/request.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s0="urn:MessageService" xmlns:atls="http://tempuri.org/vc/atl/server/"><soap:Header></soap:Header><soap:Body><s0:Message><bstrResourceId>034b7ea5-8a04-11e3-9710-0050569575d8</bstrResourceId></s0:Message></soap:Body></soap:Envelope> |
4 changes: 4 additions & 0 deletions
4
test/request-response-samples/Messages_suffixed_with__In_Out/response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"return":"-1", | ||
"bstrError":{} | ||
} |
1 change: 1 addition & 0 deletions
1
test/request-response-samples/Messages_suffixed_with__In_Out/response.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><snp:Message xmlns:snp="urn:MessageService"><return>-1</return><bstrError></bstrError></snp:Message></soap:Body></soap:Envelope> |
50 changes: 50 additions & 0 deletions
50
test/request-response-samples/Messages_suffixed_with__In_Out/soap.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0"?> | ||
<!-- ATL Server generated Web Service Description --> | ||
<definitions | ||
xmlns:s="http://www.w3.org/2001/XMLSchema" | ||
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" | ||
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" | ||
xmlns:s0="urn:MessageService" | ||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:atls="http://tempuri.org/vc/atl/server/" | ||
targetNamespace="urn:MessageService" | ||
xmlns="http://schemas.xmlsoap.org/wsdl/" | ||
> | ||
<types> | ||
<s:schema targetNamespace="urn:MessageService" attributeFormDefault="qualified" elementFormDefault="qualified"> | ||
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</s:schema> | ||
</types> | ||
<message name="MessageIn"> | ||
<part name="bstrResourceID" type="s:string"/> | ||
</message> | ||
<message name="MessageOut"> | ||
<part name="return" type="s:string"/> | ||
<part name="bstrError" type="s:string"/> | ||
</message> | ||
<portType name="MessageServiceSoap"> | ||
<operation name="Message"> | ||
<input message="s0:MessageIn"/> | ||
<output message="s0:MessageOut"/> | ||
</operation> | ||
</portType> | ||
<binding name="MessageServiceSoap" type="s0:MessageServiceSoap"> | ||
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> | ||
<operation name="Message"> | ||
<soap:operation soapAction="#Message" style="rpc"/> | ||
<input> | ||
<soap:body use="encoded" namespace="urn:MessageService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" namespace="urn:MessageService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</output> | ||
</operation> | ||
</binding> | ||
<service name="MessageService"> | ||
<port name="MessageServiceSoap" binding="s0:MessageServiceSoap"> | ||
<soap:address location="http://localhost/Message/Message.dll?Handler=Default"/> | ||
</port> | ||
</service> | ||
</definitions> |
3 changes: 3 additions & 0 deletions
3
test/request-response-samples/Messages_suffixed_with__Input_Output/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"bstrResourceId": "034b7ea5-8a04-11e3-9710-0050569575d8" | ||
} |
1 change: 1 addition & 0 deletions
1
test/request-response-samples/Messages_suffixed_with__Input_Output/request.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s0="urn:MessageService" xmlns:atls="http://tempuri.org/vc/atl/server/"><soap:Header></soap:Header><soap:Body><s0:Message><bstrResourceId>034b7ea5-8a04-11e3-9710-0050569575d8</bstrResourceId></s0:Message></soap:Body></soap:Envelope> |
4 changes: 4 additions & 0 deletions
4
test/request-response-samples/Messages_suffixed_with__Input_Output/response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"return":"-1", | ||
"bstrError":{} | ||
} |
1 change: 1 addition & 0 deletions
1
test/request-response-samples/Messages_suffixed_with__Input_Output/response.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><snp:Message xmlns:snp="urn:MessageService"><return>-1</return><bstrError></bstrError></snp:Message></soap:Body></soap:Envelope> |
50 changes: 50 additions & 0 deletions
50
test/request-response-samples/Messages_suffixed_with__Input_Output/soap.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0"?> | ||
<!-- ATL Server generated Web Service Description --> | ||
<definitions | ||
xmlns:s="http://www.w3.org/2001/XMLSchema" | ||
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" | ||
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" | ||
xmlns:s0="urn:MessageService" | ||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:atls="http://tempuri.org/vc/atl/server/" | ||
targetNamespace="urn:MessageService" | ||
xmlns="http://schemas.xmlsoap.org/wsdl/" | ||
> | ||
<types> | ||
<s:schema targetNamespace="urn:MessageService" attributeFormDefault="qualified" elementFormDefault="qualified"> | ||
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</s:schema> | ||
</types> | ||
<message name="MessageInput"> | ||
<part name="bstrResourceID" type="s:string"/> | ||
</message> | ||
<message name="MessageOutput"> | ||
<part name="return" type="s:string"/> | ||
<part name="bstrError" type="s:string"/> | ||
</message> | ||
<portType name="MessageServiceSoap"> | ||
<operation name="Message"> | ||
<input message="s0:MessageInput"/> | ||
<output message="s0:MessageOutput"/> | ||
</operation> | ||
</portType> | ||
<binding name="MessageServiceSoap" type="s0:MessageServiceSoap"> | ||
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> | ||
<operation name="Message"> | ||
<soap:operation soapAction="#Message" style="rpc"/> | ||
<input> | ||
<soap:body use="encoded" namespace="urn:MessageService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" namespace="urn:MessageService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</output> | ||
</operation> | ||
</binding> | ||
<service name="MessageService"> | ||
<port name="MessageServiceSoap" binding="s0:MessageServiceSoap"> | ||
<soap:address location="http://localhost/Message/Message.dll?Handler=Default"/> | ||
</port> | ||
</service> | ||
</definitions> |
3 changes: 3 additions & 0 deletions
3
test/request-response-samples/Messages_suffixed_with__Request_Response/request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"bstrResourceId": "034b7ea5-8a04-11e3-9710-0050569575d8" | ||
} |
1 change: 1 addition & 0 deletions
1
test/request-response-samples/Messages_suffixed_with__Request_Response/request.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s0="urn:MessageService" xmlns:atls="http://tempuri.org/vc/atl/server/"><soap:Header></soap:Header><soap:Body><s0:Message><bstrResourceId>034b7ea5-8a04-11e3-9710-0050569575d8</bstrResourceId></s0:Message></soap:Body></soap:Envelope> |
4 changes: 4 additions & 0 deletions
4
test/request-response-samples/Messages_suffixed_with__Request_Response/response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"return":"-1", | ||
"bstrError":{} | ||
} |
1 change: 1 addition & 0 deletions
1
test/request-response-samples/Messages_suffixed_with__Request_Response/response.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><snp:Message xmlns:snp="urn:MessageService"><return>-1</return><bstrError></bstrError></snp:Message></soap:Body></soap:Envelope> |
50 changes: 50 additions & 0 deletions
50
test/request-response-samples/Messages_suffixed_with__Request_Response/soap.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0"?> | ||
<!-- ATL Server generated Web Service Description --> | ||
<definitions | ||
xmlns:s="http://www.w3.org/2001/XMLSchema" | ||
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" | ||
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" | ||
xmlns:s0="urn:MessageService" | ||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:atls="http://tempuri.org/vc/atl/server/" | ||
targetNamespace="urn:MessageService" | ||
xmlns="http://schemas.xmlsoap.org/wsdl/" | ||
> | ||
<types> | ||
<s:schema targetNamespace="urn:MessageService" attributeFormDefault="qualified" elementFormDefault="qualified"> | ||
<s:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</s:schema> | ||
</types> | ||
<message name="MessageRequest"> | ||
<part name="bstrResourceID" type="s:string"/> | ||
</message> | ||
<message name="MessageResponse"> | ||
<part name="return" type="s:string"/> | ||
<part name="bstrError" type="s:string"/> | ||
</message> | ||
<portType name="MessageServiceSoap"> | ||
<operation name="Message"> | ||
<input message="s0:MessageRequest"/> | ||
<output message="s0:MessageResponse"/> | ||
</operation> | ||
</portType> | ||
<binding name="MessageServiceSoap" type="s0:MessageServiceSoap"> | ||
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> | ||
<operation name="Message"> | ||
<soap:operation soapAction="#Message" style="rpc"/> | ||
<input> | ||
<soap:body use="encoded" namespace="urn:MessageService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</input> | ||
<output> | ||
<soap:body use="encoded" namespace="urn:MessageService" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> | ||
</output> | ||
</operation> | ||
</binding> | ||
<service name="MessageService"> | ||
<port name="MessageServiceSoap" binding="s0:MessageServiceSoap"> | ||
<soap:address location="http://localhost/Message/Message.dll?Handler=Default"/> | ||
</port> | ||
</service> | ||
</definitions> |