12

SOAP? Why would you use that?

I am using Ruby Enterprise Edition and Rails 3 to write my web application. The application uses Ustream's Watershed white label broadcasting services to provide live streaming for my users. Unfortunately I have hit a snag during development. Watershed allows an application to provide it's own authentication layer through the implementation of a SOAP service on the application side of things. This authentication layer must be implemented in SOAP 1.2 to work with Watershed. To my great dismay, it seems that the Ruby community has moved on past ye'old SOAP towards a brighter future filled with REST and Unicorns.

This makes me happy 99.9% of the time. However right now I need to make a SOAP 1.2 endpoint in my shiny new Rails 3 application.

If anyone has any suggestions or libraries that I can use, I would be very thankful.

Things I have done already

  • Tried the built in SOAP support in Ruby. Unfortunatly it seems that it does not support SOAP 1.2.
  • Looked at WSO2 but didn't want to build an extensive set of Ruby extensions on my server just to support SOAP.
  • Thought about hard-coding xml responses before deciding that I am a lazy programmer.
Carl Sverre
  • 1,139
  • 10
  • 19

4 Answers4

5

It's been a while since this Q was posted, but hey, SOAP isn't speeding off either. I guess you've implemented something, care to share?

Anyway, as a kind of answer, I've been blessed with a customer forcing me to consume his SOAP services (their awesome SOA platform doesn't support other formats...) both for pulling and pushing data. I only consume, as I provide nice and clean RESTful Web Services myself for others. I've been using savon (french for soap?) with great success

http://savonrb.com

If you're truly lazy, you'll hard code the SOAP envelope structure and input your dynamic data. Here's a simple example.

def soap_envelope(pCode)
  "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:prod='http://xmlns.aBigCompany.com/path/to/NeededService'>
     <soapenv:Header/>
     <soapenv:Body>
        <something:NeededServiceRequest>
           <something:productCode>#{pCode}</something:productCode>
        </something:NeededServiceRequest>
     </soapenv:Body>
  </soapenv:Envelope>"
end

And this is one way to use it

products_wsdl = Savon::Client.new "http://ipAtBigCo:xxxx/path/to/services/NeededService?wsdl"
begin
  response = products_wsdl.process! do |soap| 
    soap.xml = soap_envelope("someProductCode")
  end
rescue => e
  MyLogger.error "Error: SOAP call for code #{pCode} failed. ++"
  raise e
end
response.to_hash # This is the nice part 

About SOAP 1.2, savon supports it. About actually being a SOAP service provider, I haven't done it in rails (fight it!) and can only wish you good luck. Having to develop the stupid WSDLs yourself is the real pain with SOAP services. Hope this helps anyone.

rubiii
  • 6,903
  • 2
  • 38
  • 51
oma
  • 38,642
  • 11
  • 71
  • 99
  • 1
    Thanks for the answer Morten. :) I looked at Savon, but it is a client and thus does not help me out. Luckily I have moved on from that project and ended up not having to implement the soap end-point at all. Thanks for sharing the "hard coded SOAP" structure as I think that for someone trying to do what I was doing, that might be their best bet. ~_~ – Carl Sverre Nov 04 '10 at 06:14
3

If you cannot avoid SOAP in Rails 3, then try wash_out gem. You can find it at: https://github.com/roundlake/wash_out

We used in our system. It is not fool-proof and still undergoing some changes, at least you would get started

Although Rails 3 onwards, they have kind-of stopped supporting SOAP - wash_out gem helps you to get started with creating SOAP webservice faster. Anyone interested should have a look at the wash_out wiki on github. In our case, client wanted a SOAP webservice to be exposed; we tried to go the REST way. In the end, we had to say yes to SOAP. I tried aws, soap4r - but wash_out turned out to be best fit.

arrk-shoba
  • 39
  • 3
1

You can use this gem for soap implementation

savon

Mukesh
  • 921
  • 10
  • 23
0

You may find what you are looking for here http://aws.rubyonrails.org/

Will
  • 8,102
  • 5
  • 30
  • 32
  • Thanks for the answer Will. As far as I know AWS does not support 1.2, nor does it support Rails 3 (yet). If I am mistaken please let me know. – Carl Sverre Apr 16 '10 at 17:27