Skip to content

Commit

Permalink
Fix input/output for style="rpc" operations (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
hss-mateus committed Feb 27, 2024
1 parent 3bf2502 commit 835f50e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
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'
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

0 comments on commit 835f50e

Please sign in to comment.