如何使用rails返回soap webservice中的对象列表

时间:2013-12-17 12:31:12

标签: ruby-on-rails-3 web-services soap savon

我正在使用Savon访问soap webservice,但我只能返回一个结果,而我想要的是一系列结果。

这是我的电话:

response = client.call(:get_events,message:{username:“xxxx”,password:“xxxxxxxx”,company_code:“12TCE”})

我希望'响应'返回所有记录,其中company_code为“12TCE”,并且我能够输出所有记录,例如:

response.to_hash [:get_events_response] .each do | a | 一[:回报] [:项目] [:名字] 端

如何根据需要返回所有记录和输出?

更新1:

这是指向wsdl:http://www.brrmedia.co.uk/webservices/event/index.php?wsdl

的链接

这是我得到的回复:

HTTPI POST request to www.brrmedia.co.uk (httpclient)
SOAP response (status 200)
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.brrmedia.co.uk/webservices/event" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <ns1:getEventsResponse xmlns:ns1="http://www.brrmedia.co.uk/webservices/event">
      <return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:objEvent[1]">
        <item xsi:type="tns:objEvent">
          <id xsi:type="xsd:int">119466</id>
          <name xsi:type="xsd:string">blur Group - 2000 projects milestone</name>
          <summary xsi:type="xsd:string"/>
          <location xsi:type="xsd:string"/>
          <date xsi:type="xsd:string">2013-12-17 11:30</date>
          <link xsi:type="xsd:string">http://www.brrmedia.co.uk/event/119466/partner/brrsoap</link>
          <company xsi:type="tns:objCompany">
            <name xsi:type="xsd:string">blur Group</name>
            <codes xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:objCompanyCode[1]">
              <item xsi:type="tns:objCompanyCode">
                <code xsi:type="xsd:string">BLUR</code>
                <collection xsi:type="xsd:string">London Stock Exchange (AIM)</collection>
              </item>
            </codes>
            <website xsi:type="xsd:string">http://www.blurgroup.com/</website>
            <category xsi:type="xsd:string">Technology</category>
          </company>
          <presenter xsi:type="tns:objPresenter">
            <name xsi:type="xsd:string"> Philip Letts</name>
            <image xsi:type="xsd:string">http://www.brrmedia.co.uk/getimage/id/31215</image>
          </presenter>
          <media xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:objMediaItem[3]">
            <item xsi:type="tns:objMediaItem">
              <src xsi:type="xsd:string">http://s3-us-west-2.amazonaws.com/brr-streamguys/files/BLUR/blur20131217.pdf</src>
              <duration xsi:type="xsd:string">00:00:00</duration>
              <filesize xsi:type="xsd:string">380</filesize>
              <media_type xsi:type="xsd:string">pdf</media_type>
            </item>
            <item xsi:type="tns:objMediaItem">
              <src xsi:type="xsd:string">http://s3-us-west-2.amazonaws.com/brr-streamguys/files/BLUR/BLUR20131217</src>
              <duration xsi:nil="true" xsi:type="xsd:string"/>
              <filesize xsi:nil="true" xsi:type="xsd:string"/>
              <media_type xsi:type="xsd:string">presimages</media_type>
            </item>
            <item xsi:type="tns:objMediaItem">
              <src xsi:type="xsd:string">http://s3-us-west-2.amazonaws.com/brr-streamguys/files/BLUR/BLUR20131217editv1.mp3</src>
              <duration xsi:type="xsd:string">00:07:54</duration>
              <filesize xsi:type="xsd:string">5557</filesize>
              <media_type xsi:type="xsd:string">audio</media_type>
            </item>
          </media>
          <type xsi:type="xsd:string">audio</type>
          <height xsi:type="xsd:int">900</height>
          <width xsi:type="xsd:int">680</width>
        </item>
      </return>
    </ns1:getEventsResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

0 个答案:

没有答案