aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/test
diff options
context:
space:
mode:
authorLeon Breedt <bitserf@gmail.com>2005-07-13 06:05:13 +0000
committerLeon Breedt <bitserf@gmail.com>2005-07-13 06:05:13 +0000
commitdfc422b784d3f62daa5a876d65b0ac983c33408a (patch)
treeb435cb969ed40ace9355aa6e3791b766a5bde566 /actionwebservice/test
parentf29ce1f35670866cb86faedeabb28a33215a143f (diff)
downloadrails-dfc422b784d3f62daa5a876d65b0ac983c33408a.tar.gz
rails-dfc422b784d3f62daa5a876d65b0ac983c33408a.tar.bz2
rails-dfc422b784d3f62daa5a876d65b0ac983c33408a.zip
always send back SOAP responses as UTF-8, we can't guarantee that SOAP4R
supports any encoding sent by caller. add documentation describing how to ensure :string types don't get converted into :base64 by SOAP4R when containing non-ASCII chars and $KCODE is not set to a value. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1822 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionwebservice/test')
-rw-r--r--actionwebservice/test/abstract_dispatcher.rb15
-rw-r--r--actionwebservice/test/dispatcher_action_controller_soap_test.rb25
2 files changed, 23 insertions, 17 deletions
diff --git a/actionwebservice/test/abstract_dispatcher.rb b/actionwebservice/test/abstract_dispatcher.rb
index e01d902ae1..4f8cd1fb4c 100644
--- a/actionwebservice/test/abstract_dispatcher.rb
+++ b/actionwebservice/test/abstract_dispatcher.rb
@@ -4,6 +4,7 @@ require 'stringio'
class ActionController::Base; def rescue_action(e) raise e end; end
module DispatcherTest
+ Utf8String = "One World Caf\303\251"
WsdlNamespace = 'http://rubyonrails.com/some/namespace'
class Node < ActiveRecord::Base
@@ -58,6 +59,7 @@ module DispatcherTest
api_method :hash_struct_return, :returns => [[Person]]
api_method :thrower
api_method :void
+ api_method :test_utf8, :returns => [:string]
api_method :hex, :expects => [:base64], :returns => [:string]
api_method :unhex, :expects => [:string], :returns => [:base64]
end
@@ -223,6 +225,10 @@ module DispatcherTest
@void_called = @method_params
end
+ def test_utf8
+ Utf8String
+ end
+
def hex(s)
return s.unpack("H*")[0]
end
@@ -398,12 +404,6 @@ module DispatcherCommonTests
raise NotImplementedError
end
- def update_request(ap_request)
- end
-
- def check_response(ap_response)
- end
-
def protocol
@protocol
end
@@ -453,11 +453,10 @@ module DispatcherCommonTests
# puts body
ap_request = protocol.encode_action_pack_request(service_name, public_method_name, body, :request_class => ActionController::TestRequest)
ap_request.env.update(request_env)
- update_request(ap_request)
ap_response = ActionController::TestResponse.new
container.process(ap_request, ap_response)
# puts ap_response.body
- check_response(ap_response)
+ @response_body = ap_response.body
public_method_name, return_value = protocol.decode_response(ap_response.body)
unless is_exception?(return_value) || virtual
return_value = method.cast_returns(return_value)
diff --git a/actionwebservice/test/dispatcher_action_controller_soap_test.rb b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
index 6e332828f2..16a20ea73e 100644
--- a/actionwebservice/test/dispatcher_action_controller_soap_test.rb
+++ b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
@@ -67,16 +67,23 @@ class TC_DispatcherActionControllerSoap < Test::Unit::TestCase
assert_equal(["bloggerCat1", "bloggerCat2"], blogger_cats)
end
- protected
- def update_request(ap_request)
- ap_request.env.update('HTTP_CONTENT_TYPE' => 'text/xml; charset=us-ascii')
- end
-
- def check_response(ap_response)
- assert_equal 'text/xml; charset=us-ascii', ap_response.headers['Content-Type']
- assert_match /xml.*?encoding="us-ascii"/, ap_response.body
- end
+ def test_utf8
+ @direct_controller.web_service_exception_reporting = true
+ $KCODE = 'u'
+ assert_equal(Utf8String, do_method_call(@direct_controller, 'TestUtf8'))
+
+ # If $KCODE is not set to UTF-8, any strings with non-ASCII UTF-8 data
+ # will be sent back as base64 by SOAP4R. By the time we get it here though,
+ # it will be decoded back into a string. So lets read the base64 value
+ # from the message body directly.
+ $KCODE = 'NONE'
+ do_method_call(@direct_controller, 'TestUtf8')
+ retval = SOAP::Processor.unmarshal(@response_body).body.response
+ assert retval.is_a?(SOAP::SOAPBase64)
+ assert_equal "T25lIFdvcmxkIENhZsOp", retval.data.to_s
+ end
+ protected
def exception_message(soap_fault_exception)
soap_fault_exception.detail.cause.message
end