Project

shapewear

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Shapewear is a Ruby library for handling SOAP requests from within your Rails or Sinatra application. It makes your fat services look skinny.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2
~> 2.7.0
>= 0
>= 0

Runtime

>= 2.1.2
>= 1.5.0
 Project Readme

shapewear Build Status

Shapewear make your fat service look skinny.

Most of the inspiration for this gem came from Savon and HTTParty, thanks Daniel Harrington (a.k.a. rubiii) and John Nunemaker!

Work in Progress

This gem is still in early development. It's only working for some very basic cases. Any contribution and feedback is welcome.

Roadmap

  • Add more tests;
  • Add support for SOAP 1.2;
  • Add cleaner integration on Rails and Sinatra (Rack middleware?).

Installation

Shapewear is available through Rubygems and can be installed via:

$ gem install shapewear

Introduction

First, describe your SOAP service:

require "shapewear"

class MyFirstService
  include Shapewear

  wsdl_namespace 'http://services.example.com/v1'

  endpoint_url 'http://localhost:3000/my_first_service'

  operation :hello, :parameters => [[:name, String]], :returns => String
  def hello(name)
    "hello, #{name}"
  end

  operation :sum, :parameters => [[:x, Fixnum], [:y, Fixnum]], :returns => Fixnum
  def sum(x, y)
    x + y
  end

  operation :get_user_info, :parameters => [[:email, String]], :returns => { :name => String, :birthday => DateTime }
  def get_user_info(email)
    User.find_by_email(email)
  end
end

Then bind to your web application in a non-intrusive way.

Rails example:

# don't forget to write the appropriate routes
class MyFirstServiceController < ApplicationController
  def wsdl
    render :xml => MyHelloService.to_wsdl
  end

  def serve
    render :xml => MyHelloService.serve(request)
  end
end

Sinatra example:

class MySinatraApp < Sinatra::App
  get "my_first_service/wsdl" do
    content_type "application/xml"
    MyHelloService.to_wsdl
  end

  post "my_first_service" do
    content_type "application/xml"
    MyHelloService.serve(request)
  end
end