🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.ruby
1 messages
1 total messages Started by Daniel Podlejski Fri, 14 Mar 2008 07:24
dla potomności - dziwny problem z XML-RPC
#988
Author: Daniel Podlejski
Date: Fri, 14 Mar 2008 07:24
35 lines
1717 bytes
Przytrafił mi się dziwny problem z XML-RPC.

Standardowe wywołanie:

rpc = ActionWebService::Client::XmlRpc.new(...)
rpc.sendMessage(msg)

Kończyło się takim wyjątkiem:

NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of Array.

Winny okazał się sam serwis (java, bodajrze spring), który choć
zwracał poprawną odpowiedź, to zwracał ja nie do końca poprawnie.
Brakowało nagłówków Content-Type.

Na szczęście dało się to ładnie załatać:

module XMLRPC
  module ParseContentType
    def parse_content_type(str)
      if str.nil?
        str = 'text/xml; charset=utf-8'
      end
      a, *b = str.split(";")
      return a.strip, *b
    end
  end
end

Zostawiam dla potomności, może komuś się przyda.  Ja straciłem na
to sporo czasu szukając przyczyny zupełnie gdzie indziej ;)

-- 
Daniel Podlejski
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads