[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ssl xml rpc

David Weldon

1/24/2007 7:59:00 AM

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"?>
<transaction>
<methodCall>
...blah blah...
</methodCall>
</transaction>
ENDXML
resp = client.post("https://api.ultradns.net:8755&...)

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:

1) Is there a better way of doing all of this? (something other than
http-access2)
2) Is there something obviously wrong with the above code? Keep in mind
the XML part is verified in a working perl script.

Thanks!

--
Posted via http://www.ruby-....

7 Answers

brabuhr

1/24/2007 3:28:00 PM

0

On 1/24/07, David Weldon <dweldon@gmail.com> wrote:
> I need to make remote procedure calls to a server that has a
> non-standard RPC protocol. ...
>
> 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:
>
> 1) Is there a better way of doing all of this? (something other than
> http-access2)
> 2) Is there something obviously wrong with the above code? Keep in mind
> 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.

David Weldon

1/24/2007 11:57:00 PM

0

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?

--
Posted via http://www.ruby-....

James Britt

1/25/2007 3:13:00 AM

0

David Weldon wrote:
> 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?
>

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 Britt

http://www.ru... - Ruby Help & Documentation
http://beginni... - Beginning Ruby: The Online Book
http://www.rub... - The Ruby Store for Ruby Stuff
http://www.jame... - Playing with Better Toys

David Weldon

1/25/2007 5:41:00 AM

0

> 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.

--
Posted via http://www.ruby-....

brabuhr

1/25/2007 2:49:00 PM

0

On 1/25/07, David Weldon <dweldon@gmail.com> 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.linuxjournal.com/ar...
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-op...
if(BIO_write(bio, buf, len) <= 0)
{
}

brabuhr

1/25/2007 2:57:00 PM

0

On 1/25/07, brabuhr@gmail.com <brabuhr@gmail.com> wrote:
> On 1/25/07, David Weldon <dweldon@gmail.com> 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.asp...
s = TCPSocket.new(...)
ssl = OpenSSL::SSL::SSLSocket.new(...)

ssl.connect
ssl.write(...)
ssl.gets

ssl.close
s.close

David Weldon

1/25/2007 7:56:00 PM

0

http://www.koders.com/ruby/fid5E43597C85CD23E775CC0AD7C6507389969DF8E6.asp...
> 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

--
Posted via http://www.ruby-....