Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ivanshamatov/sinatra-soap
Adding ability to sinatra to work with soap
https://github.com/ivanshamatov/sinatra-soap
Last synced: about 2 months ago
JSON representation
Adding ability to sinatra to work with soap
- Host: GitHub
- URL: https://github.com/ivanshamatov/sinatra-soap
- Owner: IvanShamatov
- License: mit
- Created: 2013-11-25T13:47:52.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-04T10:12:40.000Z (over 7 years ago)
- Last Synced: 2024-10-14T02:13:02.829Z (2 months ago)
- Language: Ruby
- Size: 47.9 KB
- Stars: 10
- Watchers: 5
- Forks: 15
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Sinatra::Soap — Not maintained.
[![Build Status](https://travis-ci.org/IvanShamatov/sinatra-soap.png?branch=master)](https://travis-ci.org/IvanShamatov/sinatra-soap) [![Code Climate](https://codeclimate.com/github/IvanShamatov/sinatra-soap.png)](https://codeclimate.com/github/IvanShamatov/sinatra-soap) [![Gem Version](https://badge.fury.io/rb/sinatra-soap.png)](http://badge.fury.io/rb/sinatra-soap)
Sinatra-soap gem makes task to create SOAP API really simple. Inspired by WashOut gem for Rails. But remember, the only reason why you should use SOAP is legacy code.
## Overview
In case of simplicity and quick first working release:
## Usage
A classic application would work like that:
```ruby
require 'sinatra'
require 'sinatra/soap'soap "SomeAction" do
do_something_with_params # hash to be returned
end
```A modular application would look like that:
```ruby
require 'sinatra/base'
require 'sinatra/soap'class SoapAPI < Sinatra::Base
#remember to register extenstion if you are using modular style
register Sinatra::Soapsoap "SomeAction" do
params # hash to be returned
end
end
```## Settings
* **:wsdl_route** — url for getting wsdl, either static or dynamically generated file
```ruby
set :wsdl_route, '/wsdl'
```
Defines route for app to response with wsdl. Default is '/wsdl'* **:endpoint** — url for sending SOAP Requests
```ruby
set :endpoint, '/action'
```
Defines route for SOAP Requests. Default is '/action'* **:wsdl_file** — app will send static file, if this setting specified
```ruby
set :wsdl_file, "wsdl.xml"
```
If wsdl_file is set, app will try to read wsdl file from ```:public_folder``` (by default ./public directory). If file does not exist, app will raise an error. You also don't need to specify ```:namespace``` or ```:service``` if you want to serve static wsdl.* **:namespace** — wsdl setting, required for generating wsdl
```ruby
set :namespace, "http://schemas.xmlsoap.org/wsdl/"
```
Namespace is taking it's place in ```xmlns:tns``` and ```targetNamespace``` definitions of SOAP Envelope* **:service** — wsdl setting, required for generating wsdl
```ruby
set :service, "sinatra"
```
Service involved in ```portType```, ```binding``` and ```service``` definitions as a prefix for name attribute.## Soap Arguments
If you want to be able to generate wsdl on a fly, you need to specify incoming and outgoing nodes with their types.
```ruby
soap :test, in: {circle: {center: {x: :integer,
y: :integer},
radius: :double}
},
out: nil do
params #=> {circle: {center: {x: 3, y: 2}, radius: 12.0} }
nil
end
```The code above will respond to request like this:
```xml
3
2
12.0
```