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 input/output for style="rpc" operations #119

Merged
merged 1 commit into from
Feb 27, 2024
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
11 changes: 8 additions & 3 deletions lib/wasabi/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def parse_operations
# TODO: check for soap namespace?
soap_operation = operation.element_children.find { |node| node.name == 'operation' }
soap_action = soap_operation['soapAction'] if soap_operation
soap_document = soap_operation["style"] if soap_operation
soap_document = soap_operation['style'] == 'document' if soap_operation

if soap_action || soap_document
soap_action = soap_action.to_s
Expand Down Expand Up @@ -260,8 +260,13 @@ def input_output_for(operation, input_output)
end

message_ns_id, message_type = nil
message_ns_id = port_message_ns_id
message_type = port_message_type

soap_operation = operation.element_children.find { |node| node.name == 'operation' }

if soap_operation.nil? || soap_operation['style'] != 'rpc'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind explaining the change here? why do we branch into here only if nil soap operation or the style is (presumably) document

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be refactored to unless soap_operation&.get_attribute('style') == 'rpc'

It just disables the behavior introduced in 4.0 for RPC operations. When the value is nil or document it keeps the current behavior.

message_ns_id = port_message_ns_id
message_type = port_message_type
end

# When there is a parts attribute in soap:body element, we should use that value
# to look up the message part from messages array.
Expand Down
38 changes: 38 additions & 0 deletions spec/fixtures/rpc_operation.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<definitions
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
name="ExampleService"
targetNamespace="http://www.example.com"
xmlns:tns="http://www.example.com"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<message name="ExampleOperationRequest">
<part name="ExampleField" type="xs:string"/>
</message>
<message name="ExampleOperationResponse">
<part name="ExampleField" type="xs:string"/>
</message>
<portType name="ExamplePortType">
<operation name="ExampleOperation">
<input message="tns:ExampleOperationRequest"/>
<output message="tns:ExampleOperationResponse"/>
</operation>
</portType>
<binding name="ExampleBinding" type="tns:ExamplePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="ExampleOperation">
<soap:operation soapAction="urn:ExampleInterface-ExamplePortType#ExampleOperation" style="rpc"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:ExampleInterface-ExamplePortType"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:ExampleInterface-ExamplePortType"/>
</output>
</operation>
</binding>
<service name="ExampleService">
<port name="ExamplePort" binding="tns:ExampleBinding">
<soap:address location="http://example.com/ExampleService.dll/soap/ExamplePortType"/>
</port>
</service>
</definitions>
26 changes: 26 additions & 0 deletions spec/wasabi/document/rpc_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# frozen_string_literal: true

require "spec_helper"

describe Wasabi::Document do
context "with: rpc_operation.wsdl" do
subject { Wasabi::Document.new(fixture(:rpc_operation).read) }

describe "#operations" do
subject { super().operations }

it do
should include(
{
example_operation: {
action: "urn:ExampleInterface-ExamplePortType#ExampleOperation",
input: "ExampleOperation",
output: "ExampleOperation",
namespace_identifier: "tns"
}
}
)
end
end
end
end