Skip to content

Commit 299a671

Browse files
authored
Parse Input/Output When Operation Style is Document (#114)
1 parent 9406aff commit 299a671

9 files changed

+66892
-24
lines changed

lib/wasabi/parser.rb

+7-5
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ def parse_operations
144144
# TODO: check for soap namespace?
145145
soap_operation = operation.element_children.find { |node| node.name == 'operation' }
146146
soap_action = soap_operation['soapAction'] if soap_operation
147+
soap_document = soap_operation["style"] if soap_operation
147148

148-
if soap_action
149+
if soap_action || soap_document
149150
soap_action = soap_action.to_s
150151
action = soap_action && !soap_action.empty? ? soap_action : name
151152

@@ -247,8 +248,7 @@ def input_output_for(operation, input_output)
247248
port_type_operation = @port_type_operations[binding_type][operation_name]
248249
end
249250

250-
port_type_input_output = port_type_operation &&
251-
port_type_operation.element_children.find { |node| node.name == input_output }
251+
port_type_input_output = port_type_operation&.element_children&.find { |node| node.name == input_output }
252252

253253
# TODO: Stupid fix for missing support for imports.
254254
# Sometimes portTypes are actually included in a separate WSDL.
@@ -260,6 +260,8 @@ def input_output_for(operation, input_output)
260260
end
261261

262262
message_ns_id, message_type = nil
263+
message_ns_id = port_message_ns_id
264+
message_type = port_message_type
263265

264266
# When there is a parts attribute in soap:body element, we should use that value
265267
# to look up the message part from messages array.
@@ -270,8 +272,8 @@ def input_output_for(operation, input_output)
270272
end
271273

272274
message = @messages[port_message_type]
273-
port_message_part = message.element_children.find do |node|
274-
soap_body_parts.nil? ? (node.name == 'part') : ( node.name == 'part' && node['name'] == soap_body_parts)
275+
port_message_part = message&.element_children&.find do |node|
276+
soap_body_parts.nil? ? (node.name == "part") : (node.name == "part" && node["name"] == soap_body_parts)
275277
end
276278

277279
if port_message_part && port_element = port_message_part.attribute('element')

spec/fixtures/workday.wsdl

+66,772
Large diffs are not rendered by default.

spec/wasabi/document/geotrust_spec.rb

+29-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,35 @@
3030
subject { super().operations }
3131
it do
3232
should include(
33-
{ :get_quick_approver_list => { :input => "GetQuickApproverList", :action => "GetQuickApproverList", :parameters=>{:Request=>{:name=>"Request", :type=>"GetQuickApproverListInput"}}}},
34-
{ :hello => { :input => "hello", :action => "hello", :parameters=>{:Input=>{:name=>"Input", :type=>"string"}} } }
35-
)
33+
{
34+
get_quick_approver_list: {
35+
input: "GetQuickApproverList",
36+
output: "GetQuickApproverListResponse",
37+
action: "GetQuickApproverList",
38+
namespace_identifier: "s1",
39+
parameters: {
40+
Request: {
41+
name: "Request",
42+
type: "GetQuickApproverListInput"
43+
}
44+
}
45+
}
46+
},
47+
{
48+
hello: {
49+
input: "hello",
50+
output: "helloResponse",
51+
action: "hello",
52+
namespace_identifier: "s1",
53+
parameters: {
54+
Input: {
55+
name: "Input",
56+
type: "string"
57+
}
58+
}
59+
}
60+
}
61+
)
3662
end
3763
end
3864

spec/wasabi/document/namespaced_actions_spec.rb

+27-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,33 @@
2929
describe '#operations' do
3030
subject { super().operations }
3131
it do
32-
should include(
33-
{ :delete_client => { :input => "Client.Delete", :output => "Client.DeleteResponse", :action => "http://api.example.com/api/Client.Delete", :namespace_identifier => "tns" } },
34-
{ :get_clients => { :input => "User.GetClients", :output => "User.GetClientsResponse", :action => "http://api.example.com/api/User.GetClients", :namespace_identifier => "tns" } },
35-
{ :get_api_key => { :input => "User.GetApiKey", :output => "User.GetApiKeyResponse", :action => "http://api.example.com/api/User.GetApiKey", :namespace_identifier => "tns" } }
36-
)
37-
end
32+
should include(
33+
{
34+
delete_client: {
35+
input: "Client.Delete",
36+
output: "Client.DeleteResponse",
37+
action: "http://api.example.com/api/Client.Delete",
38+
namespace_identifier: "tns"
39+
}
40+
},
41+
{
42+
get_clients: {
43+
input: "User.GetClients",
44+
output: "User.GetClientsResponse",
45+
action: "http://api.example.com/api/User.GetClients",
46+
namespace_identifier: "tns"
47+
}
48+
},
49+
{
50+
get_api_key: {
51+
input: "User.GetApiKey",
52+
output: "User.GetApiKeyResponse",
53+
action: "http://api.example.com/api/User.GetApiKey",
54+
namespace_identifier: "tns"
55+
}
56+
}
57+
)
58+
end
3859
end
3960

4061
end

spec/wasabi/document/no_namespace_spec.rb

+27-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,33 @@
2929
describe '#operations' do
3030
subject { super().operations }
3131
it do
32-
should include(
33-
{ :get_user_login_by_id => { :input => "GetUserLoginById", :output => "GetUserLoginById", :action => "/api/api/GetUserLoginById", :namespace_identifier => "typens" } },
34-
{ :get_all_contacts => { :input => "GetAllContacts", :output =>"GetAllContacts", :action => "/api/api/GetAllContacts", :namespace_identifier => "typens" } },
35-
{ :search_user => { :input => "SearchUser", :output =>"SearchUser", :action => "/api/api/SearchUser", :namespace_identifier => nil } }
36-
)
37-
end
32+
should include(
33+
{
34+
get_user_login_by_id: {
35+
input: "GetUserLoginById",
36+
output: "GetUserLoginByIdResponse",
37+
action: "/api/api/GetUserLoginById",
38+
namespace_identifier: "typens"
39+
}
40+
},
41+
{
42+
get_all_contacts: {
43+
input: "GetAllContacts",
44+
output: "GetAllContactsResponse",
45+
action: "/api/api/GetAllContacts",
46+
namespace_identifier: "typens"
47+
}
48+
},
49+
{
50+
search_user: {
51+
input: "SearchUser",
52+
output: "SearchUserResponse",
53+
action: "/api/api/SearchUser",
54+
namespace_identifier: nil
55+
}
56+
}
57+
)
58+
end
3859
end
3960

4061
end

spec/wasabi/document/savon295_spec.rb

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
subject { super().operations }
1212
it do
1313
should include(
14-
{ :sendsms => { :input => "sendsms", :output => "sendsms", :action => "sendsms", :namespace_identifier => "tns" } }
14+
{
15+
sendsms: {
16+
input: "sendsmsRequest",
17+
output: "sendsmsResponse",
18+
action: "sendsms",
19+
namespace_identifier: "tns"
20+
}
21+
}
1522
)
1623
end
1724
end

spec/wasabi/parser/no_message_parts_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
it 'falls back to using the message type in the port element' do
1717
# Operation's input has no part element in the message, so using the message type.
18-
expect(subject.operations[:save][:input]).to eq('Save')
18+
expect(subject.operations[:save][:input]).to eq("SaveSoapIn")
1919

2020
# Operation's output has part element in the message, so using part element's type.
2121
expect(subject.operations[:save][:output]).to eq('SaveResponse')
@@ -26,7 +26,7 @@
2626
end
2727

2828
it 'gracefully handles port messages without a colon' do
29-
expect(subject.operations[:delete][:input]).to eq('Delete')
29+
expect(subject.operations[:delete][:input]).to eq("DeleteSoapIn")
3030
expect(subject.operations[:delete][:output]).to eq('DeleteResponse')
3131
expect(subject.operations[:delete][:namespace_identifier]).to be_nil
3232
end

spec/wasabi/parser/tradetracker_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
let(:xml) { fixture(:tradetracker).read }
1414

1515
it 'parses the operations' do
16-
expect(subject.operations[:get_feeds][:input]).to eq('getFeeds')
16+
expect(subject.operations[:get_feeds][:input]).to eq("GetFeedsMessage")
1717
end
1818
end
1919
end

spec/wasabi/parser/workday_spec.rb

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# frozen_string_literal: true
2+
3+
require "spec_helper"
4+
5+
describe Wasabi::Parser do
6+
context "with: workday.wsdl" do
7+
subject do
8+
parser = Wasabi::Parser.new Nokogiri::XML(xml)
9+
parser.parse
10+
parser
11+
end
12+
13+
let(:xml) { fixture(:workday).read }
14+
15+
it "parses the operations" do
16+
expect(subject.operations[:get_customer_invoices][:input]).to eq("Get_Customer_Invoices_Request")
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)