Tag: 回复

如何从ruby客户端解析SOAP响应?

我正在学习Ruby,我编写了以下代码来了解如何使用SOAP服务: require ‘soap/wsdlDriver’ wsdl=”http://www.abundanttech.com/webservices/deadoralive/deadoralive.wsdl” service=SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver weather=service.getTodaysBirthdays(‘1/26/2010’) 我得到的回应是: #<SOAP::Mapping::Object:0x80ac3714 {http://www.abundanttech.com/webservices/deadoralive} getTodaysBirthdaysResult=#<SOAP::Mapping::Object:0x80ac34a8 {http://www.w3.org/2001/XMLSchema}schema=#<SOAP::Mapping::Object:0x80ac3214 {http://www.w3.org/2001/XMLSchema}element=#<SOAP::Mapping::Object:0x80ac2f6c {http://www.w3.org/2001/XMLSchema}complexType=#<SOAP::Mapping::Object:0x80ac2cc4 {http://www.w3.org/2001/XMLSchema}choice=#<SOAP::Mapping::Object:0x80ac2a1c {http://www.w3.org/2001/XMLSchema}element=#<SOAP::Mapping::Object:0x80ac2774 {http://www.w3.org/2001/XMLSchema}complexType=#<SOAP::Mapping::Object:0x80ac24cc {http://www.w3.org/2001/XMLSchema}sequence=#<SOAP::Mapping::Object:0x80ac2224 {http://www.w3.org/2001/XMLSchema}element=[#, #, #, #, #, #] >>>>>>> {urn:schemas-microsoft-com:xml-diffgram-v1}diffgram=#<SOAP::Mapping::Object:0x80abe6c4 {}NewDataSet=#<SOAP::Mapping::Object:0x80ac1220 {}Table=[#, #<SOAP::Mapping::Object:0x80b778f4 {}FullName="Feiffer, Jules" {}BirthDate="01/26/1929" {}DeathDate=# {}Age=”81″ {}KnownFor=”Cartoonists” {}DeadOrAlive=”Alive”>]>>>> 我很难找出如何解析并在一个漂亮的表中显示返回的信息,甚至只是如何遍历记录并访问每个元素(即FullName,Age等)。 我经历了整个“getTodaysBirthdaysResult.methods – Object.new.methods”并继续努力尝试找出如何访问元素,但后来我进入arrays,我迷路了。 任何可以提供的帮助将不胜感激。

解析@username的post

我已经建立了类似Twitter的@replies,允许用户通过用户每日邮件相互联系…类似于stackoverflow。 以此为指导https://github.com/kltcalamay/sample_app/compare/original-version…master 如何解析/扫描post,然后将@usernames替换为该用户页面的链接 post的例子。 Kevins Post: @Pzpcreations @john @steve hey everyone lets all hang out today 我想扫描/解析post,然后将用户@Pzpcreations @john @steve链接到他们的个人资料 我尝试在Dailypost模型中创建一个方法,将用户名存储在数组中….但IDK如何替换并将它们链接到相应的用户页面 def username_link str = self.content_html recipient = str.scan(USERNAME_REGEX) end 这给了我[“@Pzpcreations”,“@ john”,“@ step”] 请帮帮我….新到铁路:) 楷模 class Recipient < ActiveRecord::Base attr_accessible :dailypost_id, :user_id belongs_to :user belongs_to :dailypost end class User ‘Recipient’, :dependent => :destroy has_many :received_replies, :through […]