Hi,
I have trouble setting a SOAP::RPC::Driver class encoding (for the
response) to utf-8. My response contains accentuated character that are
not ok without this. I dont understand why the mandatorychaset= method
doesnt do the trick so I''m looking for some lights here ;-)
Here is my driver class code :
require ''sw/SecuriteServiceWeb''
require ''sw/SecuriteServiceWebMappingRegistry''
require ''soap/rpc/driver''
class SecuriteServiceServerPortType < ::SOAP::RPC::Driver
DefaultEndpointUrl = $props[RAILS_ENV][''securite_sw_url'']
NsSecuriteServiceWeb = "SecuriteServiceWeb"
Methods = [
[ XSD::QName.new(NsSecuriteServiceWeb, "getUtilisateurXML"),
"",
"getUtilisateurXML",
[ ["in", "codeApplication",
["::SOAP::SOAPString"]],
["in", "certificat",
["::SOAP::SOAPString"]],
["retval", "return",
["::SOAP::SOAPString"]] ],
{ :request_style => :rpc, :request_use => :encoded,
:response_style => :rpc, :response_use => :encoded,
:faults => {} }
]
]
def initialize(endpoint_url = nil)
endpoint_url ||= DefaultEndpointUrl
super(endpoint_url, nil)
self.mapping_registry SecuriteServiceWebMappingRegistry::EncodedRegistry
self.literal_mapping_registry
SecuriteServiceWebMappingRegistry::LiteralRegistry
init_methods
end
private
def init_methods
Methods.each do |definitions|
opt = definitions.last
if opt[:request_style] == :document
add_document_operation(*definitions)
else
add_rpc_operation(*definitions)
qname = definitions[0]
name = definitions[2]
if qname.name != name and qname.name.capitalize =name.capitalize
::SOAP::Mapping.define_singleton_method(self, qname.name) do
|*arg|
__send__(name, *arg)
end
end
end
end
end
end
And here is my call method :
def obtain_xml_element(tag)
xml_element = nil
require ''soap/soap''
require ''sw/SecuriteServiceWebDriver''
begin
driver = SecuriteServiceServerPortType.new
#Why is this doest work ?
driver.mandatorycharset = ''utf-8''
data_xml = driver.getUtilisateurXML("CDI",
cookies[:certificat].to_s.split(''-'')[0].to_s)
data = REXML::Document.new(data_xml)
if tag.is_a?(Array)
xml_element = tag.collect {|t| REXML::XPath.first( data, t
).to_s}
else
xml_element = REXML::XPath.first( data, tag ).to_s
end
rescue Exception => e
logger.error $!, $@
ExceptionNotifier.deliver_exception_notification(e, self,
request, {:xml_element => xml_element, :lacapitale_certificat =>
cookies[:lacapitale_certificat].to_s})
ensure
return xml_element
end
end
Finally, the response looks like :
<?xml version=''1.0''
encoding=''ISO-8859-1''?><com.lacapitale.commun.model.securite.dto.Utilisateur>
<dateNaissance
class=''sql-date''>1980-12-12</dateNaissance>
<codeUtilisateur>MACCENT99</codeUtilisateur>
<nom>Ééâûôé</nom>
<prenom>Ééâûôé</prenom>
Any helps appreciated !
Thx !
Serge Savoie
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---