Implementing a SOAP 1.2 server with Rails 3 Implementing a SOAP 1.2 server with Rails 3 xml xml

Implementing a SOAP 1.2 server with Rails 3


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")  endrescue => e  MyLogger.error "Error: SOAP call for code #{pCode} failed. ++"  raise eendresponse.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.


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.


You can use this gem for soap implementation

savon