🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.ruby
Article #988

dla potomności - dziwny problem z XML-RPC

#988
From: 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
Technical Details
Message-ID: <slrnftka0r.db8.underley@uriel.lft>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.tpinternet.pl!newsfeed.neostrada.pl!news.underley.eu.org!home.underley.eu.org!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.tpinternet.pl!newsfeed.neostrada.pl!news.underley.eu.org!home.underley.eu.org!not-for-mail
From: Daniel Podlejski <underley@underley.eu.org>
Newsgroups: pl.comp.lang.ruby
Subject: dla potomności - dziwny problem z XML-RPC
Date: Fri, 14 Mar 2008 07:24:11 +0000 (UTC)
Organization: Lakshmi & Underley Home
Lines: 35
Message-ID: <slrnftka0r.db8.underley@uriel.lft>
NNTP-Posting-Host: uriel.lft
Mime-Version: 1.0
X-Trace: uriel.lft 1205479451 13673 192.168.66.254 (14 Mar 2008 07:24:11 GMT)
X-Complaints-To: usenet@underley.eu.org
NNTP-Posting-Date: Fri, 14 Mar 2008 07:24:11 +0000 (UTC)
User-Agent: slrn/0.9.8.1pl2 (Debian)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit