开发者

Empty String API arguments for actionwebservice received as "SOAP::Mapping::Object" instead of ""

开发者 https://www.devze.com 2022-12-25 21:38 出处:网络
I\'ve built an API using actionwebservice and when a client calls a method to pass in an empty string (\"\"), it\'s to_s value is # instead of \"\". But when the client passes in \"hello\", it\'s to_s

I've built an API using actionwebservice and when a client calls a method to pass in an empty string (""), it's to_s value is # instead of "". But when the client passes in "hello", it's to_s value is "hello".

class UsersApiController < ApiController

  w开发者_JAVA百科eb_service_api UserApi

  def create_or_update(arg1)
    Rails.logger.info arg1.to_s # Displays "#<SOAP::Mapping::Object:0x3a89c08>" if arg1 is an empty string
  end
end


It's not the best way, but this is the only solution I've found so far:

arg1 = "" if /#<SOAP::Mapping::Object:/ =~ arg1.to_s


arg1 = nil if arg1.kind_of?(SOAP::Mapping::Object) 
0

精彩评论

暂无评论...
验证码 换一张
取 消