<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - NET HTTP POST XML returned.. need help]]></title>
		<link>http://railsforum.com/viewtopic.php?id=51947</link>
		<description><![CDATA[The most recent posts in NET HTTP POST XML returned.. need help.]]></description>
		<lastBuildDate>Thu, 10 Jan 2013 14:28:26 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[NET HTTP POST XML returned.. need help]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=158216#p158216</link>
			<description><![CDATA[<p>I&#039;m new to Ruby and to Rails. I&#039;m trying to build an app that consumes another XML based API web service and I&#039;m stuck. Please let me know if I am doing something wrong.I need to POST XML to a URL. When I do this, the web service that I am posting to returns XML. I need to set that XML as a Ruby object and extract the value of an attribute. So, this is what I have in my controller:<br /></p><div class="codebox"><pre><code>require &#039;net/http&#039;

class ServersController &lt; ApplicationController

  def index(myURL=&quot;http://myxmlserviceapi.com&quot;, myName=&quot;xuser&quot;, myPassword=&quot;foo&quot;)

    @url = myURL

    @uri = URI.parse @url

    xml_req = &quot;&lt;xLogin inName=&#039;#{myName}&#039; inPassword=&#039;#{myPassword}&#039;&gt;&lt;/xLogin&gt;&quot;

    request = Net::HTTP::Post.new(@url)

    request.body = xml_req

    http = Net::HTTP

    #left off here need to parse the xml and look for the value of the outCookie attribute within the &quot;xLogin&quot; tag returned by the xLogin POST
    #sample xml returned by POST: &lt;XLogin cookie=&quot;&quot; response=&quot;yes&quot; outCookie=&quot;1357323804/bace9755-0445-496b-973a-0dfaf23d26c1&quot; outRefreshPeriod=&quot;600&quot;&gt; &lt;/XLogin&gt;

      #session[myCookie=&gt;&quot;thisCookieValue&quot;]

  end

end</code></pre></div><p>Then, just for kicks in my index view file index.html.erb I&#039;d like to do something like this:<br /></p><div class="codebox"><pre><code>&lt;h2&gt;&lt;%= session[myCookie %&gt;&lt;/h2&gt;</code></pre></div><p>Can anyone offer some advice to help me get unstuck here?</p>]]></description>
			<author><![CDATA[dummy@example.com (the1drewharris)]]></author>
			<pubDate>Thu, 10 Jan 2013 14:28:26 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=158216#p158216</guid>
		</item>
	</channel>
</rss>
