Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1622

Show
Ignore:
Timestamp:
09/13/05 23:29:50 (3 years ago)
Author:
nahi
Message:

added 'soap.envelope.use_numeric_character_reference' (boolean) option to let query XML use numeric character reference in XML, not plain UTF-8 character. GoogleSearch? server seems to not allow plain UTF-8 character since 2005-08-15 update. closes #147.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/generator.rb

    r1604 r1622  
    2929  attr_accessor :default_encodingstyle 
    3030  attr_accessor :generate_explicit_type 
     31  attr_accessor :use_numeric_character_reference 
    3132 
    3233  def initialize(opt = {}) 
     
    3940    @elementformdefault = opt[:elementformdefault] 
    4041    @attributeformdefault = opt[:attributeformdefault] 
     42    @use_numeric_character_reference = opt[:use_numeric_character_reference] 
    4143    @indentstr = opt[:no_indent] ? '' : '  ' 
    4244    @buf = @indent = @curr = nil 
     
    191193  EncodeCharRegexp = Regexp.new("[#{EncodeMap.keys.join}]") 
    192194  def encode_string(str) 
    193     @buf << str.gsub(EncodeCharRegexp) { |c| EncodeMap[c] } 
     195    if @use_numeric_character_reference and !XSD::Charset.is_us_ascii(str) 
     196      str.gsub!(EncodeCharRegexp) { |c| EncodeMap[c] } 
     197      @buf << str.unpack("U*").collect { |c| 
     198        if c == 0x9 or c == 0xa or c == 0xd or (c >= 0x20 and c <= 0x7f) 
     199          c.chr 
     200        else 
     201          sprintf("&#x%x;", c) 
     202        end 
     203      }.join 
     204    else 
     205      @buf << str.gsub(EncodeCharRegexp) { |c| EncodeMap[c] } 
     206    end 
    194207  end 
    195208 
  • trunk/lib/soap/mapping/wsdlencodedregistry.rb

    r1597 r1622  
    150150    soap_obj = nil 
    151151    if type <= XSD::XSDString 
    152       str = XSD::Charset.encoding_conv(obj, Thread.current[:SOAPExternalCES]
    153         XSD::Charset.encoding) 
     152      str = XSD::Charset.encoding_conv(obj.to_s
     153        Thread.current[:SOAPExternalCES], XSD::Charset.encoding) 
    154154      soap_obj = type.new(str) 
    155155      mark_marshalled_obj(obj, soap_obj) 
  • trunk/lib/soap/rpc/proxy.rb

    r1618 r1622  
    255255    opt[:generate_explicit_type] = @generate_explicit_type 
    256256    opt[:no_indent] = @options["soap.envelope.no_indent"] 
     257    opt[:use_numeric_character_reference] = 
     258      @options["soap.envelope.use_numeric_character_reference"] 
    257259    opt.update(hash) if hash 
    258260    opt 
  • trunk/sample/wsdl/googleSearch/wsdlDriver.rb

    r1619 r1622  
    1515 
    1616google = SOAP::WSDLDriverFactory.new(GOOGLE_WSDL).create_rpc_driver 
     17google.options["soap.envelope.use_numeric_character_reference"] = true 
    1718google.wiredump_dev = STDOUT if $DEBUG 
    1819#google.generate_explicit_type = false