[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Trying to send a soap message directly at a server

Max Russell

2/2/2007 1:46:00 PM

I've now tried 2 different methods of sending a soap message (read in
from a file) at a server, one using the net/http library the other a
socket.

require 'soap/wsdlDriver'
require 'rexml/document'
#require 'net/http'
require 'socket'
include Socket::Constants

file = File.new("PDSUpdate.xml")
doc = REXML::Document.new(file)
#puts doc
#http.post("http://inpsesrh02.inpses.co.uk:..., doc)

socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
sockaddr = Socket.pack_sockaddr_in( 7779,
'inpsesrh02.inpses.co.uk/orabpel/default/' )
socket.connect( sockaddr )
socket.puts doc
socket.close

Can anyone please tell me the simplest way of sending a SOAP message
directly at an address and port. I don't need the WSDL as I already know
the available methods, and just want to write a test stub.

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

10 Answers

mid

2/2/2007 2:02:00 PM

0

On Fri, 02 Feb 2007 22:46:17 +0900, Max Russell wrote:

> I've now tried 2 different methods of sending a soap message (read in
> from a file) at a server, one using the net/http library the other a
> socket.
>

Have you tried SOAP4r?

http://dev.ctor....

Mid

Max Russell

2/2/2007 2:29:00 PM

0

mid wrote:
> On Fri, 02 Feb 2007 22:46:17 +0900, Max Russell wrote:
>
>> I've now tried 2 different methods of sending a soap message (read in
>> from a file) at a server, one using the net/http library the other a
>> socket.
>>
>
> Have you tried SOAP4r?
>
> http://dev.ctor....
>
> Mid

I have had a look previously, what I'm needing is a howto I suppose. The
documentation around some of this stuff is a bit flaky..

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

mid

2/2/2007 2:57:00 PM

0

On Fri, 02 Feb 2007 22:46:17 +0900, Max Russell wrote:

> Can anyone please tell me the simplest way of sending a SOAP message
> directly at an address and port. I don't need the WSDL as I already know
> the available methods, and just want to write a test stub.
>

Here's what I do in the console (for testing purposes):

require "soap/wsdlDriver"
wsdl_url = "http://webservices.globaladdress.net/globaladdress.asmx?...
factory = SOAP::WSDLDriverFactory.new(wsdl_url)
driver = factory.create_rpc_driver

This allows me to use the SOAP services available on the GlobalAddress
server.

I can do a driver.methods to find out what methods (services) are
available but in reality I already know what methods are available to me.

Do you have a WSDL file to reference?


Disclosure: I'm new to all this too so this may be a case of the blind
leading the blind but I am successfully consuming services except I've
also hit a snag too but that's the topic of another thread :)

Brian Candler

2/4/2007 9:21:00 PM

0

On Fri, Feb 02, 2007 at 10:46:17PM +0900, Max Russell wrote:
> I've now tried 2 different methods of sending a soap message (read in
> from a file) at a server, one using the net/http library the other a
> socket.

So what happens when you try these methods?

What does tcpdump (Linux) or ethereal (Windows) show at the network level?

tcpdump -i eth0 -n -s1500 -vX tcp port 80

> require 'soap/wsdlDriver'
> require 'rexml/document'

Why require these libraries? AFAICT you're just trying to send a
pre-existing XML file over HTTP.

> #require 'net/http'
> require 'socket'
> include Socket::Constants
>
> file = File.new("PDSUpdate.xml")
> doc = REXML::Document.new(file)
> #puts doc
> #http.post("http://inpsesrh02.inpses.co.uk:..., doc)

I'd suggest you don't parse the document using REXML. Just read it in as a
file, and then squirt it out over the HTTP connection. I'm not sure how
http.post will cope with being given an REXML::Document object.

Try "ri Net::HTTP" for some samples of how to do a HTTP POST.
(or "ri1.8 Net::HTTP" under Ubuntu).

Capture the result in a variable, e.g. res = http.post ...
and inspect it.

Perhaps you should be posting to a more specific URL, e.g.
http.post("http://inpsesrh02.inpses.co.uk:7778/foo/m..., doc)

> socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
> sockaddr = Socket.pack_sockaddr_in( 7779,
> 'inpsesrh02.inpses.co.uk/orabpel/default/' )
> socket.connect( sockaddr )
> socket.puts doc
> socket.close

Doing it this way you'd want a TCPSocket.
See http://www.rubycentral.com/book/lib_ne...
for some examples.

HTH,

Brian.

Max Russell

2/7/2007 11:55:00 AM

0

Brian Candler wrote:

> So what happens when you try these methods?
>
> What does tcpdump (Linux) or ethereal (Windows) show at the network
> level?
>
> tcpdump -i eth0 -n -s1500 -vX tcp port 80

That nothing was going out over HTTP at all.

>
>> require 'soap/wsdlDriver'
>> require 'rexml/document'
>
> Why require these libraries? AFAICT you're just trying to send a
> pre-existing XML file over HTTP.

The soap/wsdlDriver was a hangover from my hacking (in vain) session...

>> #require 'net/http'
>> require 'socket'
>> include Socket::Constants
>>
>> file = File.new("PDSUpdate.xml")
>> doc = REXML::Document.new(file)
>> #puts doc
>> #http.post("http://inpsesrh02.inpses.co.uk:..., doc)
>
> I'd suggest you don't parse the document using REXML. Just read it in as
> a
> file, and then squirt it out over the HTTP connection. I'm not sure how
> http.post will cope with being given an REXML::Document object.
>
> Try "ri Net::HTTP" for some samples of how to do a HTTP POST.
> (or "ri1.8 Net::HTTP" under Ubuntu).

I've had a look at this documentation, the sections pertaining to POST
all refer to form data (e.g. looking at a search box and posting info,
setting dates and posting etc.) , rather than an individual POST of a
file.

> Capture the result in a variable, e.g. res = http.post ...
> and inspect it.
>
> Perhaps you should be posting to a more specific URL, e.g.
> http.post("http://inpsesrh02.inpses.co.uk:7778/foo/m..., doc)


>> socket = Socket.new( AF_INET, SOCK_STREAM, 0 )
>> sockaddr = Socket.pack_sockaddr_in( 7779,
>> 'inpsesrh02.inpses.co.uk/orabpel/default/' )
>> socket.connect( sockaddr )
>> socket.puts doc
>> socket.close
>
> Doing it this way you'd want a TCPSocket.
> See http://www.rubycentral.com/book/lib_ne...
> for some examples.

Think I'd prefer to avoid the socket route if possible anyway.


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

Brian Candler

2/7/2007 2:39:00 PM

0

On Wed, Feb 07, 2007 at 08:54:43PM +0900, Max Russell wrote:
> > I'd suggest you don't parse the document using REXML. Just read it in as
> > a
> > file, and then squirt it out over the HTTP connection. I'm not sure how
> > http.post will cope with being given an REXML::Document object.
> >
> > Try "ri Net::HTTP" for some samples of how to do a HTTP POST.
> > (or "ri1.8 Net::HTTP" under Ubuntu).
>
> I've had a look at this documentation, the sections pertaining to POST
> all refer to form data (e.g. looking at a search box and posting info,
> setting dates and posting etc.) , rather than an individual POST of a
> file.

It looks easy enough to me:

require 'net/http'

doc = <<EOS
<foo>
bar!
</foo>
EOS

res = nil
Net::HTTP.start("rubyforge.org", 80) do |http|
res = http.post('/wibble/wobble', doc)
end
puts res.inspect

Max Russell

2/7/2007 7:04:00 PM

0

Brian Candler wrote:
> On Wed, Feb 07, 2007 at 08:54:43PM +0900, Max Russell wrote:
>> setting dates and posting etc.) , rather than an individual POST of a
>> file.
>
> It looks easy enough to me:
>
> require 'net/http'
>
> doc = <<EOS
> <foo>
> bar!
> </foo>
> EOS
>
> res = nil
> Net::HTTP.start("rubyforge.org", 80) do |http|
> res = http.post('/wibble/wobble', doc)
> end
> puts res.inspect

I'll try that, thanks. RI didn't turn up anything like that example. It
has sections on posting form data, but nothing with a simple post.

ta

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

Linda

11/19/2010 4:27:00 AM

0

X-No-Archive:
On Nov 17, 7:06 pm, "Society" <Soci...@feminism.is.invalid> wrote:
> X-DoublePlus-Permanent-Archive:
>
> "Linda" <b_brazil...@hotmail.com> wrote in message
>
> news:b1806ce0-d371-4d34-8c45-2629dba56f9e@n24g2000prj.googlegroups.com...
>
>
>
> > Hi Tesla,
> > I guess you better send them vitamin D tablets:
>
> >http://news.myjoyonline.com/international/201011...
>
> Polio was almost wiped out in Africa until Mohammedan
> imams got infected with conspiracy theory memes
> and began hindering vaccination campaigns.
>
> http://www.capitalismmagazine.com/index.php...
>
> --
>    Ever wonder why Christians developed science
>    and Muslims, Buddhists and atheists didn't?

The problem is that there are people that believe this rubbish. It
takes only 10% of the population to stop vaccinating and the diseases
start taking hold again. That is why I asked Tesla in an earlier post
why there are no emergency departments for naturopaths or homeopaths.
The reason I asked her was because when they really have to put their
beliefs to the ultimate test, they fail! No amount of natural medicine
is going to protect you against polio, measles, mumps, etc....

Checkmate

11/19/2010 9:08:00 PM

0

Warning! Always wear ANSI approved safety goggles when reading posts by
Checkmate. Oh, yeah... I should also mention that Tesla said the following:
>
> On 11/18/2010 11:26 PM, Linda wrote:
> > X-No-Archive:
> > On Nov 17, 7:06 pm, "Society"<Soci...@feminism.is.invalid> wrote:
> >> X-DoublePlus-Permanent-Archive:
> >>
> >> "Linda"<b_brazil...@hotmail.com> wrote in message
> >>
> >> news:b1806ce0-d371-4d34-8c45-2629dba56f9e@n24g2000prj.googlegroups.com...
> >>
> >>
> >>
> >>> Hi Tesla,
> >>> I guess you better send them vitamin D tablets:
> >>
> >>> http://news.myjoyonline.com/international/201011...
> >>
> >> Polio was almost wiped out in Africa until Mohammedan
> >> imams got infected with conspiracy theory memes
> >> and began hindering vaccination campaigns.
> >>
> >> http://www.capitalismmagazine.com/index.php...
> >>
> >> --
> >> Ever wonder why Christians developed science
> >> and Muslims, Buddhists and atheists didn't?
> >
> > The problem is that there are people that believe this rubbish. It
> > takes only 10% of the population to stop vaccinating and the diseases
> > start taking hold again. That is why I asked Tesla in an earlier post
> > why there are no emergency departments for naturopaths or homeopaths.
> > The reason I asked her was because when they really have to put their
> > beliefs to the ultimate test, they fail! No amount of natural medicine
> > is going to protect you against polio, measles, mumps, etc....
> >
>
>
> Perhaps the real problem is that... <SMACK!>

Shaddup, idiot.



--

Checkmate
Copyright ? 2010
all rights reserved

http://www.youtube.com/watch?v=iT48YM-5nBA&featu...

Read what others are saying about Checkmate!
____________________________________________________________________

"You have got to be the biggest butt fucking moron in this place.
You use socks and then admit to it? What the fuck is the point?"

-Wildhare, dazed and confused
____________________________________________________________________

"You can sit there all you want and spit out all the denial you can
muster, it still doesn?t change the fact that you are the current
king shit of the puppeteers in this group."

-Ragnar, blinded by the light
____________________________________________________________________

"Nor do I engage in juvenile gay lames like others do."

-Ragnar the Hypocrite, right after posting numerous gay lames.
____________________________________________________________________

"Mature, intelligent people don't consider being gay a derogatory issue
worthy of name calling."

-Ragnar the Liar, right after posting another bunch of gay lames.
____________________________________________________________________

"Shouldn't you be making a blanket, doing the dishes or some other form
of woman's work?

-Ragnar the Hypocrite, right after flaming Greg for being a racist.
____________________________________________________________________

"Try some English the next time you need to get your point accross."

-Ragnar the spelling cop, who apparently can't spell "across."
____________________________________________________________________

"As we all can tell by the fact that you spend half you fucking life
right here, casing me around."

-Ragnar the Hypocrite, right after criticizing Kachina for her typos.

Steve L

11/20/2010 2:01:00 AM

0

Checkmate <LunaticFringe@The.Edge> said stuff on 19 Nov 2010:

> Warning! Always wear ANSI approved safety goggles when reading posts
> by Checkmate. Oh, yeah... I should also mention that Tesla said the
> following:
>>
>> On 11/18/2010 11:26 PM, Linda wrote:
>> > X-No-Archive:
>> > On Nov 17, 7:06 pm, "Society"<Soci...@feminism.is.invalid> wrote:
>> >> X-DoublePlus-Permanent-Archive:
>> >>
>> >> "Linda"<b_brazil...@hotmail.com> wrote in message
>> >>
>> >> news:b1806ce0-d371-4d34-8c45-2629dba56f9e@n24g2000prj.googlegroups.
>> >> com...
>> >>
>> >>
>> >>
>> >>> Hi Tesla,
>> >>> I guess you better send them vitamin D tablets:
>> >>
>> >>> http://news.myjoyonline.com/international/201011...
>> >>
>> >> Polio was almost wiped out in Africa until Mohammedan
>> >> imams got infected with conspiracy theory memes
>> >> and began hindering vaccination campaigns.
>> >>
>> >> http://www.capitalismmagazine.com/index.php...
>> >>
>> >> --
>> >> Ever wonder why Christians developed science
>> >> and Muslims, Buddhists and atheists didn't?
>> >
>> > The problem is that there are people that believe this rubbish. It
>> > takes only 10% of the population to stop vaccinating and the
>> > diseases start taking hold again. That is why I asked Tesla in an
>> > earlier post why there are no emergency departments for naturopaths
>> > or homeopaths. The reason I asked her was because when they really
>> > have to put their beliefs to the ultimate test, they fail! No
>> > amount of natural medicine is going to protect you against polio,
>> > measles, mumps, etc....
>> >
>>
>>
>> Perhaps the real problem is that... <SMACK!>
>
> Shaddup, idiot.
>

which dumbass made the dumbass comment about christians, muslims,
buddhists, and atheists? what a freaking dumbass.

--
@}`-,-- *with bells and motley*