wsdl-reader 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,31 +10,31 @@
10
10
  </xs:schema>
11
11
  </types>
12
12
 
13
- <message name="getFirstName">
13
+ <message name="getFirstNameRequest">
14
14
  <part name="parameters" element="tns:GetFirstName"/>
15
15
  </message>
16
- <message name="getLastName">
16
+ <message name="getLastNameRequest">
17
17
  <part name="parameters" element="tns:GetLastName"/>
18
18
  </message>
19
19
 
20
- <message name="UserNameResponse">
20
+ <message name="userNameResponse">
21
21
  <part name="parameters" element="xs:string"/>
22
22
  </message>
23
23
 
24
24
  <portType name="UserService">
25
- <operation name="getFirstName">
26
- <input message="tns:getFirstName"/>
27
- <output message="tns:UserNameResponse"/>
25
+ <operation name="getFirstNameOperation">
26
+ <input message="tns:getFirstNameRequest"/>
27
+ <output message="tns:userNameResponse"/>
28
28
  </operation>
29
- <operation name="getLastName">
30
- <input message="tns:getLastName"/>
31
- <output message="tns:UserNameResponse"/>
29
+ <operation name="getLastNameOperation">
30
+ <input message="tns:getLastNameRequest"/>
31
+ <output message="tns:userNameResponse"/>
32
32
  </operation>
33
33
  </portType>
34
34
 
35
35
  <binding name="UserServicePortBinding" type="tns:UserService">
36
36
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
37
- <operation name="getFirstName">
37
+ <operation name="getFirstNameOperation">
38
38
  <soap:operation soapAction=""/>
39
39
  <input>
40
40
  <soap:body use="literal"/>
@@ -43,7 +43,20 @@
43
43
  <soap:body use="literal"/>
44
44
  </output>
45
45
  </operation>
46
- <operation name="getLastName">
46
+ <operation name="getLastNameOperation">
47
+ <soap:operation soapAction=""/>
48
+ <input>
49
+ <soap:body use="literal"/>
50
+ </input>
51
+ <output>
52
+ <soap:body use="literal"/>
53
+ </output>
54
+ </operation>
55
+ </binding>
56
+
57
+ <binding name="UserServicePortBinding2" type="tns:UserService">
58
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
59
+ <operation name="getLastNameOperation">
47
60
  <soap:operation soapAction=""/>
48
61
  <input>
49
62
  <soap:body use="literal"/>
@@ -3,20 +3,39 @@ require "spec_helper"
3
3
  describe "WSDL Messages" do
4
4
 
5
5
  context "WSDL::Reader::Messages" do
6
- it "child of Hash" do
7
- WSDL::Reader::Messages.superclass.should be Hash
6
+ let(:parser) { WSDL::Reader::Parser.new('spec/fixtures/UserService.wsdl') }
7
+ subject { parser.messages }
8
+
9
+ it "should be kind of WSDL::Reader::Messages" do
10
+ subject.should be_kind_of WSDL::Reader::Messages
11
+ end
12
+
13
+ it "should be kind of Hash" do
14
+ subject.should be_kind_of Hash
15
+ end
16
+
17
+ it "#lookup_messages_by_element should return operation name by given element name" do
18
+ messages = subject.lookup_messages_by_element("GetFirstName")
19
+ messages.count.should eq 1
20
+ messages.first.name.should eq "getFirstNameRequest"
21
+ end
22
+
23
+ it "#lookup_operations_by_element should return operation name by given element name" do
24
+ operations = subject.lookup_operations_by_element(:input, "GetFirstName", parser.port_types)
25
+ operations.count.should eq 1
26
+ operations.first.should eq "getFirstNameOperation"
8
27
  end
28
+
9
29
  end
10
30
 
11
31
  context "WSDL::Reader::Message" do
12
32
  subject do
13
33
  parser = WSDL::Reader::Parser.new('spec/fixtures/UserService.wsdl')
14
- element = parser.document.root.children.find { |e| e.class == REXML::Element && e.name == 'message' }
15
- WSDL::Reader::Message.new(element)
34
+ parser.messages.first.last
16
35
  end
17
36
 
18
37
  its(:parts) { should eq "parameters" => { name: "parameters", element: "tns:GetFirstName", mode: :element } }
19
- its(:name) { should eq "getFirstName" }
38
+ its(:name) { should eq "getFirstNameRequest" }
20
39
  end
21
40
 
22
41
  end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe "WSDL Operation" do
4
+ let(:parser) { WSDL::Reader::Parser.new('spec/fixtures/UserService.wsdl') }
5
+ let(:binding) { parser.bindings['UserServicePortBinding'] }
6
+ let(:messages) { parser.messages }
7
+ subject { binding.operations['getFirstNameOperation'] }
8
+
9
+ it "should be WSDL::Reader::Operation instance" do
10
+ should be_a WSDL::Reader::Operation
11
+ end
12
+
13
+ its :name do
14
+ should eql "getFirstNameOperation"
15
+ end
16
+
17
+ its :method_name do
18
+ should eql "get_first_name_operation"
19
+ end
20
+
21
+ its :binding do
22
+ should be binding
23
+ end
24
+
25
+ its :soap_action do
26
+ should eq ""
27
+ end
28
+
29
+ its :style do
30
+ should eq nil
31
+ end
32
+
33
+ it "should lookup message from given messages" do
34
+ element = subject.lookup_element(parser.port_types, parser.messages)
35
+ element.should eq "GetFirstName"
36
+ end
37
+
38
+ end
@@ -11,51 +11,56 @@ describe "WSDL Parser" do
11
11
  subject { parser }
12
12
 
13
13
  context "attributes types" do
14
- it { should be_a WSDL::Reader::Parser }
14
+ it { should be_kind_of WSDL::Reader::Parser }
15
15
 
16
- its(:document) { should be_a REXML::Document }
16
+ its(:document) { should be_kind_of REXML::Document }
17
17
 
18
- its(:prefixes) { should be_a Hash }
18
+ its(:prefixes) { should be_kind_of Hash }
19
19
 
20
- its(:target_namespace) { should be_a String }
20
+ its(:target_namespace) { should be_kind_of String }
21
21
 
22
- its(:types) { should be_a SOAP::XSD }
22
+ its(:types) { should be_kind_of SOAP::XSD }
23
23
 
24
- its(:messages) { should be_a WSDL::Reader::Messages }
24
+ its(:messages) { should be_kind_of WSDL::Reader::Messages }
25
25
 
26
- its(:port_types) { should be_a WSDL::Reader::PortTypes }
26
+ its(:port_types) { should be_kind_of WSDL::Reader::PortTypes }
27
27
 
28
- its(:bindings) { should be_a WSDL::Reader::Bindings }
28
+ its(:bindings) { should be_kind_of WSDL::Reader::Bindings }
29
29
 
30
- its(:services) { should be_a SOAP::WSDL::Services }
30
+ its(:services) { should be_kind_of SOAP::WSDL::Services }
31
31
  end
32
32
 
33
33
  context "attributes values" do
34
34
  #its(:document) { clean_xml(subject.document.to_s).should eql clean_xml(File.read('spec/fixtures/UserService.wsdl')) }
35
35
 
36
36
  its(:prefixes) do
37
- should eq "soap" => "http://schemas.xmlsoap.org/wsdl/soap/",
38
- "tns" => "http://example.com/UserService/",
39
- "xs" => "http://www.w3.org/2001/XMLSchema",
40
- "__default__" => "http://schemas.xmlsoap.org/wsdl/"
37
+ should eq "soap" => "http://schemas.xmlsoap.org/wsdl/soap/",
38
+ "tns" => "http://example.com/UserService/",
39
+ "xs" => "http://www.w3.org/2001/XMLSchema",
40
+ "__default__" => "http://schemas.xmlsoap.org/wsdl/"
41
41
  end
42
42
 
43
43
  its(:target_namespace) { should eq "http://example.com/UserService/" }
44
44
 
45
45
  its(:types) { should eq SOAP::XSD.new }
46
46
 
47
- its('messages.keys') { should eq %w{getFirstName getLastName UserNameResponse} }
47
+ its('messages.keys') { should eq %w{getFirstNameRequest getLastNameRequest userNameResponse} }
48
48
 
49
49
  its('port_types.keys') { should eq %w{UserService} }
50
50
 
51
- its('bindings.keys') { should eq %w{UserServicePortBinding} }
51
+ its('bindings.keys') { should eq %w{UserServicePortBinding UserServicePortBinding2} }
52
52
 
53
53
  its('services.keys') { should eq %w{UserService} }
54
54
  end
55
55
 
56
56
  context "methods" do
57
57
 
58
- its(:get_operations) { should eql parser.bindings.get_operations }
58
+ its(:operations) { should eql parser.bindings.operations }
59
+
60
+ it "should delegate lookup_operation_by_element! to messages" do
61
+ subject.messages.should_receive(:lookup_operation_by_element!).with(1,2,3)
62
+ subject.lookup_operation_by_element! 1,2,3
63
+ end
59
64
 
60
65
  end
61
66
  end
@@ -3,30 +3,54 @@ require "spec_helper"
3
3
  describe "WSDL PortType" do
4
4
 
5
5
  def user_service_port_type
6
- {"getFirstName" => { :name => "getFirstName",
7
- :input => { :message => "tns:getFirstName" },
8
- :output => { :message => "tns:UserNameResponse" } },
6
+ { "getFirstNameOperation" => { :name => "getFirstNameOperation",
7
+ :input => { :message => "tns:getFirstNameRequest" },
8
+ :output => { :message => "tns:userNameResponse" } },
9
9
 
10
- "getLastName" => { :name => "getLastName",
11
- :input => { :message => "tns:getLastName" },
12
- :output => { :message => "tns:UserNameResponse" } }
10
+ "getLastNameOperation" => { :name => "getLastNameOperation",
11
+ :input => { :message => "tns:getLastNameRequest" },
12
+ :output => { :message => "tns:userNameResponse" } }
13
13
  }
14
14
  end
15
15
 
16
+ let(:parser) { WSDL::Reader::Parser.new('spec/fixtures/UserService.wsdl') }
17
+ let(:messages) { parser.messages }
18
+ let(:operation) { parser.bindings.operations['getFirstNameOperation'] }
19
+
16
20
  context "WSDL::Reader::PortTypes" do
17
21
  it "child of Hash" do
18
22
  WSDL::Reader::PortTypes.superclass.should be Hash
19
23
  end
24
+
25
+ it "should lookup operation message in all port types" do
26
+ message = parser.port_types.lookup_operation_message :input, operation, messages
27
+ message.should be_a WSDL::Reader::Message
28
+ message.name.should eq "getFirstNameRequest"
29
+ end
20
30
  end
21
31
 
22
32
  context "WSDL::Reader::PortType" do
33
+
23
34
  subject do
24
- parser = WSDL::Reader::Parser.new('spec/fixtures/UserService.wsdl')
25
- element = parser.document.root.children.find { |e| e.class == REXML::Element && e.name == 'portType' }
26
- WSDL::Reader::PortType.new(element)
35
+ parser.port_types.values.first
27
36
  end
28
37
 
29
38
  its(:operations) { should eq user_service_port_type }
30
39
  its(:name) { should eq "UserService" }
40
+
41
+ it "#operation_message? should check message in operation" do
42
+ operation = { input: { message: 'getFirstNameRequest' } }
43
+ subject.operation_message?(:input, operation, messages.values.first).should be_true
44
+
45
+ operation = { input: { message: 'getLastNameRequest' } }
46
+ subject.operation_message?(:input, operation, messages.values.first).should be_false
47
+ end
48
+
49
+ it "#lookup_operation_message should lookup message in messages for given type and operation" do
50
+ message = subject.lookup_operation_message :input, operation, messages
51
+ message.should be_a WSDL::Reader::Message
52
+ message.name.should eq "getFirstNameRequest"
53
+ end
54
+
31
55
  end
32
- end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wsdl-reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-16 00:00:00.000000000 Z
12
+ date: 2012-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &14889400 !ruby/object:Gem::Requirement
16
+ requirement: &14464320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *14889400
24
+ version_requirements: *14464320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard-rspec
27
- requirement: &14888980 !ruby/object:Gem::Requirement
27
+ requirement: &14463020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *14888980
35
+ version_requirements: *14463020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &14906300 !ruby/object:Gem::Requirement
38
+ requirement: &14461860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *14906300
46
+ version_requirements: *14461860
47
47
  description: Read WSDL file and parse messages, bindings, portTypes and services
48
48
  email:
49
49
  - a.sozontov@gmail.com
@@ -70,6 +70,7 @@ files:
70
70
  - lib/wsdl-reader/core_ext.rb
71
71
  - lib/wsdl-reader/error.rb
72
72
  - lib/wsdl-reader/message.rb
73
+ - lib/wsdl-reader/operation.rb
73
74
  - lib/wsdl-reader/parser.rb
74
75
  - lib/wsdl-reader/port_type.rb
75
76
  - lib/wsdl-reader/request.rb
@@ -90,6 +91,7 @@ files:
90
91
  - spec/fixtures/UserService.wsdl
91
92
  - spec/fixtures/UserService.xsd
92
93
  - spec/message_spec.rb
94
+ - spec/operation_spec.rb
93
95
  - spec/parser_spec.rb
94
96
  - spec/port_type_spec.rb
95
97
  - spec/request_spec.rb
@@ -120,3 +122,4 @@ signing_key:
120
122
  specification_version: 3
121
123
  summary: WSDL for ruby
122
124
  test_files: []
125
+ has_rdoc: