Consume Web Service With Ruby
require ’soap/wsdlDriver’
Setup The SOAP Driver Using The WSDL URI
wsdlUri = ‘<WSDL URI>’
driver = SOAP::WSDLDriverFactory.new(wsdlUri).create_rpc_driver
Invoke Web Service Method
puts driver.<method name>().to_s
Software For Every Situation.
Archive for the ‘Language’ Category.
require ’soap/wsdlDriver’
Setup The SOAP Driver Using The WSDL URI
wsdlUri = ‘<WSDL URI>’
driver = SOAP::WSDLDriverFactory.new(wsdlUri).create_rpc_driver
Invoke Web Service Method
puts driver.<method name>().to_s
Create API /app/apis/<object name>.rb
class <object name>Api < ActionWebService::API::Base
api_method :<method name>,
:expects => [{:<parameter 1 name> => :string}, {:<parameter 2 name> => :string}],
:returns => [:string]
end
Create Controller /app/controllers/<object name>_controller.rb
class <object name>Controller < ApplicationController
def <method name>(<parameter 1 name>, <parameter 2 name>)
Code Here
end
end
Install Ruby
pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/ruby-1.8.5p6.tgz
Install Gems
pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/ruby-gems-0.9.0.tgz
Install Rails And FCGI
gem install rails
gem install fcgi
Install Packages
pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/fcgi-2.4.0p2.tgz
pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/lighttpd-1.4.13p2-mysql.tgz
Example /etc/lighttpd.conf For PHP
$HTTP["host"] == “www.<example>.com” {
server.document-root = “/www/sites/<example>.com/www/”
index-file.names = ( “index.php” )
server.error-handler-404 = “/index.php”
fastcgi.server = ( “.php” =>
( “localhost” =>
(
”socket” => “/tmp/php-fastcgi.socket”,
”bin-path” => “/usr/local/bin/php-fcgi”
)
)
)
}
Example /etc/lighttpd.conf For Ruby on Rails
$HTTP["host"] == “www.<example>.com” {
server.indexfiles = ( “index.html” )
server.error-handler-404 = “/dispatch.fcgi”
server.document-root = “/Rails/public”
fastcgi.server = (”.fcgi” => ( “<example>” =>
( “min-procs” => 1,
”max-procs” => 5,
”socket” => “/tmp/rails-<example>.fastcgi”,
”bin-path” => “/Rails/public/dispatch.fcgi”,
”bin-environment” => ( “RAILS_ENV” => “production” )
)
))
}
Start Daemon on Server Startup, Add to rc.local
if [ -x /usr/local/sbin/lighttpd ] ; then
echo ‘Lighttp’
/usr/local/sbin/lighttpd -f /etc/lighttpd.conf
fi
require ‘rubygems’
require ‘aws/s3′
# Setup Connection
AWS::S3::Base.establish_connection!(
:access_key_id => ‘<access key>’,
:secret_access_key => ‘<secret key>’
)
# Initialize Variables
bucket_name = ‘<bucket name>’
file = ‘<file path>’
timestamp = Time.now.strftime(’%Y%m%d%H%M’)
# Setup Bucket And Save File
AWS::S3::Bucket.create(bucket_name)
AWS::S3::S3Object.store(timestamp + file, open(file), bucket_name)
# List Contents of Bucket
AWS::S3::Bucket.find(bucket_name).each do |current_object|
puts current_object.key
end
Download, Compile And Install Package
lynx -source “http://download.pureftpd.org/OpenBSD/misc/ports/php5.1-with-fastcgi-openbsd-4.0.tar.gz” > /tmp/php5.1-with-fastcgi-openbsd-4.0.tar.gz
Unfortunately, as of OpenBSD 4.0 there isn’t a standard package for PHP with FastCGI support.
cd /tmp
tar xzf /tmp/php5.1-with-fastcgi-openbsd-4.0.tar.gz
cd /tmp/php5 && make install clean
…wait a long, long time…
Install Subsequent PHP Support Packages
pkg_add -v /usr/ports/packages/i386/all/php5-mysql-5.1.6.tgz
/usr/local/sbin/phpxs -a mysql
Install Packages
pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/i386/fcgi-2.4.0p1.tgz
pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/i386/lighttpd-1.4.11-mysql.tgz
Example /etc/lighttpd.conf For PHP
$HTTP["host"] == “www.<example>.com” {
server.document-root = “/www/sites/<example>.com/www/”
index-file.names = ( “index.php” )
server.error-handler-404 = “/index.php”
fastcgi.server = ( “.php” =>
( “localhost” =>
(
”socket” => “/tmp/php-fastcgi.socket”,
”bin-path” => “/usr/local/bin/php-fcgi”
)
)
)
}
Example /etc/lighttpd.conf For Ruby on Rails
$HTTP["host"] == “www.<example>.com” {
server.indexfiles = ( “index.html” )
server.error-handler-404 = “/dispatch.fcgi”
server.document-root = “/Rails/public”
fastcgi.server = (”.fcgi” => ( “<example>” =>
( “min-procs” => 1,
”max-procs” => 5,
”socket” => “/tmp/rails-<example>.fastcgi”,
”bin-path” => “/Rails/public/dispatch.fcgi”,
”bin-environment” => ( “RAILS_ENV” => “production” )
)
))
}
Start Daemon on Server Startup, Add to rc.local
if [ -x /usr/local/sbin/lighttpd ] ; then
echo ‘Lighttp’
/usr/local/sbin/lighttpd -f /etc/lighttpd.conf
fi