Skip to content

Commit ce448b0

Browse files
committed
* merged from 1_5 branch.
* enabled Sriver#generate_explicit_type for literal services. * test added. * removed generated files. git-svn-id: http://dev.ctor.org/svn/soap4r/trunk@2011 23c4dcf6-64ea-0310-84d7-d424c7495ec0
1 parent 3fef307 commit ce448b0

File tree

11 files changed

+92
-153
lines changed

11 files changed

+92
-153
lines changed

lib/soap/baseData.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ module SOAPType
4848
attr_accessor :position
4949
attr_reader :extraattr
5050
attr_accessor :definedtype
51+
attr_accessor :force_typed
5152

5253
def initialize(*arg)
5354
super
@@ -60,6 +61,7 @@ def initialize(*arg)
6061
@position = nil
6162
@definedtype = nil
6263
@extraattr = {}
64+
@force_typed = false
6365
end
6466

6567
def inspect

lib/soap/encodingstyle/literalHandler.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ def initialize(charset = nil)
2929
def encode_data(generator, ns, data, parent)
3030
attrs = {}
3131
name = generator.encode_name(ns, data, attrs)
32+
if data.type and data.type.name and
33+
(@generate_explicit_type or data.force_typed)
34+
data.extraattr[XSD::AttrTypeName] = data.type
35+
end
3236
data.extraattr.each do |key, value|
33-
next if !@generate_explicit_type and key == XSD::AttrTypeName
3437
keytag = key
3538
if key.is_a?(XSD::QName)
3639
keytag = encode_attr_key(attrs, ns, key)

lib/soap/generator.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,8 @@ def encode_element(ns, obj, parent)
141141
@reftarget = nil
142142
else
143143
if obj.is_a?(SOAPEnvelope)
144-
# xsi:nil="true" can appear even if dumping without explicit type.
145144
Generator.assign_ns(attrs, ns, XSD::InstanceNamespace)
146-
if @generate_explicit_type
147-
Generator.assign_ns(attrs, ns, XSD::Namespace)
148-
end
145+
Generator.assign_ns(attrs, ns, XSD::Namespace)
149146
end
150147
obj.encode(self, ns, attrs) do |child|
151148
indent_backup, @indent = @indent, @indent + @indentstr

lib/soap/mapping/literalregistry.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ def stubobj2soap(obj, qname, definition)
136136
ele = SOAPElement.new(qname)
137137
end
138138
ele.qualified = definition.qualified
139-
if definition.type and (definition.basetype or Mapping.root_type_hint)
140-
Mapping.reset_root_type_hint
141-
ele.extraattr[XSD::AttrTypeName] = definition.type
139+
if definition.type
140+
ele.type = definition.type
141+
if definition.basetype or Mapping.root_type_hint
142+
Mapping.reset_root_type_hint
143+
ele.force_typed = true
144+
end
142145
end
143146
if qname.nil? and definition.elename
144147
ele.elename = definition.elename

lib/soap/mapping/wsdlliteralregistry.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ def obj2typesoap(obj, type)
110110
else
111111
ele = complexobj2soap(obj, type)
112112
end
113+
ele.type = type.name
114+
if type.base or Mapping.root_type_hint
115+
Mapping.reset_root_type_hint
116+
ele.force_typed = true
117+
end
113118
add_definedattributes2soap(obj, ele, type)
114119
end
115120
ele

lib/soap/rpc/proxy.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def initialize(endpoint_url, soapaction, options)
5656
# TODO: set to false by default or drop thie option in 1.6.0
5757
@allow_unqualified_element = true
5858
@default_encodingstyle = nil
59-
@generate_explicit_type = true
59+
@generate_explicit_type = nil
6060
@use_default_namespace = false
6161
@return_response_as_xml = false
6262
@headerhandler = Header::HandlerSet.new
@@ -140,6 +140,12 @@ def call(name, *params)
140140
:default_encodingstyle =>
141141
@default_encodingstyle || op_info.response_default_encodingstyle
142142
)
143+
if reqopt[:generate_explicit_type].nil?
144+
reqopt[:generate_explicit_type] = (op_info.request_use == :encoded)
145+
end
146+
if resopt[:generate_explicit_type].nil?
147+
resopt[:generate_explicit_type] = (op_info.response_use == :encoded)
148+
end
143149
env = route(req_header, req_body, reqopt, resopt)
144150
if op_info.response_use.nil?
145151
return nil

lib/xsd/mapping.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def self.xml2obj(stream, klass = nil)
3030
class Mapper
3131
MAPPING_OPT = {
3232
:default_encodingstyle => SOAP::LiteralNamespace,
33+
:generate_explicit_type => false,
3334
:root_type_hint => true
3435
}.freeze
3536

test/soap/fault/test_fault.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
require 'test/unit'
2+
require 'soap/rpc/driver'
3+
require 'soap/rpc/standaloneServer'
4+
5+
6+
module SOAP
7+
module Fault
8+
9+
10+
class TestFault < Test::Unit::TestCase
11+
12+
def setup
13+
@client = SOAP::RPC::Driver.new(nil, 'urn:fault')
14+
@client.wiredump_dev = STDERR if $DEBUG
15+
@client.add_method("hello", "msg")
16+
end
17+
18+
def teardown
19+
@client.reset_stream if @client
20+
end
21+
22+
def test_fault
23+
@client.mapping_registry = SOAP::Mapping::EncodedRegistry.new
24+
@client.test_loopback_response << <<__XML__
25+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
26+
<soap:Body>
27+
<soap:Fault>
28+
<faultcode>soap:Server</faultcode>
29+
<faultstring>DN cannot be empty</faultstring>
30+
<detail />
31+
</soap:Fault>
32+
</soap:Body>
33+
</soap:Envelope>
34+
__XML__
35+
begin
36+
@client.hello("world")
37+
assert(false)
38+
rescue ::SOAP::FaultError => e
39+
assert_equal("DN cannot be empty", e.message)
40+
end
41+
end
42+
end
43+
44+
45+
end
46+
end

test/wsdl/axisArray/itemList.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/wsdl/raa/RAA.rb

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)