Archive for the Category » Ruby «

Tuesday, February 17th, 2009 | Author: Dan Webb

Before I start I’d like to thank the SOAP4R Group for giving me a helping hand.

So we’ve got to access a SOAP interface from Ruby. Ruby’s built in library is OK but updating the library (which is an old version of the SOAP4R library) will give you some bug fixes and more features as you’d expect.

You can download the Gem from here: Link That page contains a few links to more help on SOAP4R.

From ground up following this guide (I wont rewrite mark Thomas’ guide it’s pretty concise)  I chose the “Generate classes from WSDL”. It’s just a bit more convenient and you can see which methods you can run.

So you’ll hopefully end up with file such as

  • DefaultClient.rb
  • default.rb
  • defaultDriver.rb
  • defaultMappingRegistry.rb

You’ll need 2 more files. I’ve called them main.rb & soapAuthentication.rb. Extracting the Authentication header extension out to it’s own file:

require 'soap/header/simplehandler'
class SoapAuthHeader < SOAP::Header::SimpleHandler
NAMESPACE = 'http://namespace'
DIGEST  = 'digest'
ENCODING = 'none'
SIGNATURE  = 'signature'
  def initialize()
super(XSD::QName.new(NAMESPACE, 'Trust'))
  end

def on_simple_outbound
{
"Encoding" => ENCODING,
"Digest" => DIGEST,
"Signature" => SIGNATURE
}
end
end

The above code adds Encoding, Digest and a Signature to the header when sending the SOAP envelopes. So for example on outbound it now adds:

   <env:Header>
      <n1:Trust xmlns:n1="http://questionmark.com/QMWISE/" env:mustUnderstand="0">
         <n1:Signature>9354A730B02651997F02ED97BEA3B439</n1:Signature>
         <n1:Digest>8C6504C136A975BBFC420499B4444BC3</n1:Digest>
         <n1:Encoding>none</n1:Encoding>
      </n1:Trust>
   </env:Header>

Within main.rb I’ve got

require ‘defaultDriver.rb’
require ‘soapAuthentication.rb’

## Create SOAP Driver
wsdl = “your WSDL location”

obj = DefaultSOAP.new()
obj.wiredump_dev = STDERR if $DEBUG #add some debugging to the command line

trust = SoapAuthHeader.new #create a new authentication header
obj.headerhandler << trust #adds the header to outbound envolopes

If you’ve found this useful (or wrong) leave me a comment.

Category: Ruby  | Tags: ,  | Leave a Comment
Thursday, October 23rd, 2008 | Author: Dan Webb

The hell of getting postgresql and ruby to work finally is over.

gem install ruby-postgres

however this doesn’t fully install the driver. Locate a copy of sleay32.dll, libpq.dll, comerr32.dll, libintl-2.dll, krb5_32.dll, libeay32.dll, libiconv-2.dll from here postgresql-8.3.4-1-binaries-no-installer.zip or when I upload the files, from here.

to check whether it’s installed correctly or not.

M:\>irb
irb(main):001:0> require ‘postgres’
=> true

If this is true. Go play.

Category: Ruby  | Tags: , ,  | Leave a Comment
Saturday, May 17th, 2008 | Author: Dan Webb

If you’re interested in Ruby and programming issues in general some of the following links might be useful:

Zen and the Art of Programming – A general Ruby, Rails blog, the RSS feed from this is great if you want to keep track of goings on outside the Rails community.

Ongoing - An interesting read for those who want a recap of the “interesting” bits of programming conferences like JavaOne. At the time of posting this he’s gone into full flower-picture-taking-mode, andsome of them are fantastic.

Stevey’s Blog Rants – this one is great only if you’ve got a lot of time on your hands. There’s an interesting article about the come back of dynamic lanaguages and some methods/tools to speed them up that are just around the corner.

IT Signals – useful for finding out how plug-ins that he uses work. Maybe useful, might not be.

Too-biased – musings on subjects from CouchDB to ActiveShipping (A rails merchant plug-in) and then some…

If you’ve got any more interesting sites that you regularly read along the same lines as any of the above leave me a comment and I’ll add it to the list.

Dan

Category: Rails, Ruby  | Tags: , ,  | Leave a Comment