Has anyone posted xml data over a https connection? We have a vendor product that has an API that allows for programmatic operation. Data is exchanged in xml format. The exchange occurs over https. Any tips or ideas would be appreciated. I can open https connection, but I'm not sure how to post raw XML over the connections.
Just like with HTTP: set the content type to "text/xml" and send (post) the data.
Kind regards
robert
···
On 14.08.2007 22:05, brad wrote:
Has anyone posted xml data over a https connection? We have a vendor product that has an API that allows for programmatic operation. Data is exchanged in xml format. The exchange occurs over https. Any tips or ideas would be appreciated. I can open https connection, but I'm not sure how to post raw XML over the connections.
-----Original Message-----
From: brad [mailto:byte8bits@gmail.com]
Sent: Tuesday, August 14, 2007 1:10 PM
To: ruby-talk ML
Subject: post xml over https connection
Has anyone posted xml data over a https connection? We have a
vendor product that has an API that allows for programmatic
operation. Data is exchanged in xml format. The exchange
occurs over https. Any tips or ideas would be appreciated. I
can open https connection, but I'm not sure how to post raw
XML over the connections.
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize': getaddrinfo: Name or service not known (SocketError)
from /usr/lib/ruby/1.8/net/http.rb:560:in `open'
from /usr/lib/ruby/1.8/net/http.rb:560:in `connect'
from /usr/lib/ruby/1.8/timeout.rb:48:in `timeout'
from /usr/lib/ruby/1.8/timeout.rb:76:in `timeout'
from /usr/lib/ruby/1.8/net/http.rb:560:in `connect'
from /usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
from /usr/lib/ruby/1.8/net/http.rb:542:in `start'
from /usr/lib/ruby/1.8/net/http.rb:1032:in `request'
from /usr/lib/ruby/1.8/net/http.rb:842:in `post'
The code works up until the actual post attempt. Any ideas?
Something like:
require 'net/https'
require 'uri'
url = "https://127.0.0.1:7891/path/to/xml_interface"
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if (uri.scheme == 'https')
data = "foo"
headers = {'Content-Type' => 'text/xml'}
# warning, uri.path will drop queries, use uri.path + uri.query if you need to
resp, body = nex.post(uri.path, data, headers)
HTH,
Keith
···
On 8/15/07, brad <byte8bits@gmail.com> wrote:
Robert Klemme wrote:
Perhaps I'm doing something wrong. Here's what I'm trying:
Something like:
require 'net/https'
require 'uri'
url = "https://127.0.0.1:7891/path/to/xml_interface"
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if (uri.scheme == 'https')
data = "foo"
headers = {'Content-Type' => 'text/xml'}
# warning, uri.path will drop queries, use uri.path + uri.query if you need to
resp, body = nex.post(uri.path, data, headers)
HTH,
Keith
That was silly of me. Thank you for the example and the doc pointer. I have it working now.