I need to make remote procedure calls to a server that has a
non-standard RPC protocol. It’s basically RPC but with extra types, no
required message length declaration and it’s all done over ssl. I have a
working version in perl but I’d prefer a solution in ruby. Below is what
I have so far with most of the XML removed for brevity.
require ‘rubygems’
require ‘http-access2’
client = HTTPAccess2::Client.new()
client.ssl_config.verify_mode = nil
body = <<ENDXML
<?xml version="1.0"?>
...blah blah...
ENDXML
resp = client.post("https://api.ultradns.net:8755",body)
Whenever I try to talk to the server it always replies that I have a
malformed POST. I’m using http-access2; someone packaged it as a gem but
its not in the official repository. I’d like to know:
- Is there a better way of doing all of this? (something other than
http-access2)
- Is there something obviously wrong with the above code? Keep in mind
the XML part is verified in a working perl script.
Thanks!
On 1/24/07, David W. [email protected] wrote:
the XML part is verified in a working perl script.
In situations like this I often find a network protocol analyzer like
Wireshark
very helpful. I would start a packet capture filtering on port 8755 and
run
both versions of the script (either in one capture session or two,
probably
two). Then, for both captured streams in Wireshark: Analyze → Follow
TCP
Stream. That should present a nice view of the POST request sent by
each
script.
Ok I think I discovered the problem. I need to send my XML directly
without any headers. Right now I’m sending something like:
POST /RPC2 HTTP/1.0
User-Agent: Frontier/5.1.2 (WinNT)
Host: betty.userland.com
Content-Type: text/xml
Content-length: 181
and the response I’m getting is that “POST /RPC2 HTTP/1.0” isn’t valid
XML. So my new question is:
Does anyone know a way to write raw xml data to a given server&port with
ssl? In other words do you know how to send a POST over ssl without the
headers?
David W. wrote:
XML. So my new question is:
Does anyone know a way to write raw xml data to a given server&port with
ssl? In other words do you know how to send a POST over ssl without the
headers?
I think that, by definition, a POST has POST headers.
What’s running on the server, and why isn’t it looking at the post data,
instead of the HTTP headers?
–
James B.
http://www.ruby-doc.org - Ruby Help & Documentation
http://beginningruby.com - Beginning Ruby: The Online Book
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
I think that, by definition, a POST has POST headers.
Haha, yeah I agree.
What’s running on the server, and why isn’t it looking at the post data,
instead of the HTTP headers?
Man I have no idea; it isn’t my server but I have to talk to it. I have
a solution that involves hacking up the http-access2 code so it doesn’t
dump the header. If anyone has done anything like writing raw data to an
ssl connection let me know.
On 1/25/07, David W. [email protected] wrote:
What’s running on the server, and why isn’t it looking at the post data,
instead of the HTTP headers?
Man I have no idea; it isn’t my server but I have to talk to it. I have
a solution that involves hacking up the http-access2 code so it doesn’t
dump the header. If anyone has done anything like writing raw data to an
ssl connection let me know.
I’ve not done it in Ruby, but some C examples:
An Introduction to OpenSSL Programming, Part I of II | Linux Journal
request_len=strlen(request);
r=SSL_write(ssl,request,request_len);
switch(SSL_get_error(ssl,r)){
}
http://www-128.ibm.com/developerworks/linux/library/l-openssl.html
if(BIO_write(bio, buf, len) <= 0)
{
}
On 1/25/07, [email protected] [email protected] wrote:
On 1/25/07, David W. [email protected] wrote:
What’s running on the server, and why isn’t it looking at the post data,
instead of the HTTP headers?
Man I have no idea; it isn’t my server but I have to talk to it. I have
a solution that involves hacking up the http-access2 code so it doesn’t
dump the header. If anyone has done anything like writing raw data to an
ssl connection let me know.
I’ve not done it in Ruby, but some C examples:
http://www.koders.com/ruby/fid5E43597C85CD23E775CC0AD7C6507389969DF8E6.aspx?s=socket
s = TCPSocket.new(…)
ssl = OpenSSL::SSL::SSLSocket.new(…)
ssl.connect
ssl.write(...)
ssl.gets
ssl.close
s.close
http://www.koders.com/ruby/fid5E43597C85CD23E775CC0AD7C6507389969DF8E6.aspx?s=socket
s = TCPSocket.new(...)
ssl = OpenSSL::SSL::SSLSocket.new(...)
ssl.connect
ssl.write(...)
ssl.gets
ssl.close
s.close
Fantastic! That worked just great. Thanks for the replies everyone!
-Dave