Tuesday, October 26, 2010

Nifty way (in Oracle) to get comma-separated list

There's a LISTAGG function (11g only?) that will let you create a comma-delimited list.

select LISTAGG(t.item_id, ',') WITHIN GROUP( ORDER BY t.style_id) FROM (select distinct i.item_id as item_id FROM purchase_order_item poi JOIN item i ON i.item_id = poi.item_id WHERE poi.po_id = 12345) t

Friday, May 14, 2010

Calling a SOAP 1.2 webservice from Ruby

An earlier post showed how easy it is to call a SOAP 1.1 webservice from Ruby, but what happens when you've got a SOAP 1.2 service?

soap4r is out(?) - SOAP 1.2 support is on the roadmap, but doesn't look like it's been touched in a long time.

Luckily, there's a SOAP 1.2 client available for ruby called Savon (http://github.com/rubiii/savon).

Savon seems very easy to install and use:
sudo gem install savon
In your code, you'll need to do something like:
require 'savon'

Savon::SOAP.version=2

client = Savon::Client.new 'http://foo.bar.com/someService?wsdl'

response = client.some_soap_method_in_snake_case

# to see what's avail. as a SOAP method
# client.wsdl.soap_actions

Tuesday, April 27, 2010

Upgrade JDeveloper from 11.1.1.2 to 11.1.1.3 - any ideas?



Tried to upgrade jdev on OSX where I have 11.1.1.2 running happily... get the following wonderfully useful error message: The product maintenance level of the installer (blah blah 11.1.1.3) is not compatible with the maintenance level of the product installed on your system (blah blah 11.1.1.2)

I'll post a solution if/when I find one...

[EDIT: Thanks Shay - choosing a new directory to install JDeveloper does indeed work. I'm not so sure upgrading should really require a 1.5GB download/full install into an alt. directory instead of having some sort of auto-update type feature, but at least it's working. I'll admit it's nice to not worry about dependencies. As for the Maven plugin(developer preview), I'm installing it now and crossing my fingers... ]

Tuesday, April 6, 2010

Calling a webservice from ruby

It's pretty dang easy. (We're using our hello world service in this example)
gem install soap4r --include-dependencies

Start up a friendly irb session and type in the following:
>>require "soap/wsdlDriver"
>>wsdl = "http://localhost:3000/hello_world/wsdl"
>>driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
>>driver.helloMessage("guest")
=> "Hello guest"

Faster protoyping with Rails webservices

Well, I just spent about a 1.5 days tweaking/trying to get a VERY simple Maven/CXF/Spring project deployed on WebLogic 10.3.2 (the web service part wasn't the issue... this could have been deployed on Jetty/Tomcat in minutes) - finally got it deploying to WLS from Eclipse (but not JDeveloper of course, but that's another story)

For kicks, I thought I'd see what it would take to set up a webservice in Ruby/Rails. (about 10 mins for the impatient)

There used to be a gem called actionwebservice, but it looks like it's been removed from Rails so install datanoise-actionwebservice instead.
sudo gem install datanoise-actionwebservice --source http://gems.github.com

Now, set up a quick rails app and configure the environment.
rails ws-test

Edit the config/environment.rb file:
1) Find the load_paths section and add:
config.load_paths += %W( #{RAILS_ROOT}/app/apis )

2) Find the config.gem section and add:
config.gem 'datanoise-actionwebservice', :lib => 'actionwebservice',
:version => '2.3.2'

Ok, now lets take advantage of that config work we just did...
Create the app/apis directory that we referenced in the environment.rb file
mkdir app/apis

Create the app/apis/hello_world_api.rb file
class HelloWorldApi < ActionWebService::API::Base
api_method :hello_message, :expects => [{:name=>:string}], :returns => [:string]
end

Create a controller in app/controller/hello_world_controller.rb
class HelloWorldController < ApplicationController

web_service_api HelloWorldApi
web_service_dispatching_mode :direct
wsdl_service_name 'hello_message'
web_service_scaffold :invoke

def hello_message( name )
return "Hello #{name}"
end

end

Finally, fire it up...
script/server

And browse to http://localhost:3000/hello_world/invoke for a spiffy web page or http://localhost:3000/hello_world/wsdl for the WSDL.

UPDATE (4/7/2010): You can also use script/generate on webservices
script/generate web_service HelloWorld
create app/services/
exists app/controllers/
exists test/functional/
create app/services/hello_world_api.rb
create app/controllers/hello_world_controller.rb
create test/functional/hello_world_api_test.rb

Friday, April 2, 2010

Insufficient Disk space! WebLogic 10.3.2.0 running on Mac OSX

Note: First read my post about getting JDeveloper installed - you still need to fake out the Oracle installer so it realizes you have a JDK install

Go to Oracle.com and get the Oracle WebLogic Server 11gR1 (10.3.2) - Package Installer - generic

Warning: If you double-click on the jar, you'll get a few screens in and then it will complain (completely incorrectly) about "Insufficient disk space!" regardless of how much free space you have on your machine.

The workaround is to pull up a terminal window, go to the directory holding the wls1032_generic.jar file and execute:

java -Dos.name=unix -XX:MaxPermSize=512m -Xmx1024m -jar wls1032_generic.jar

Seems the installer can't determine disk space correctly without knowing it's an unix system... should install successfully after that.

If you don't increase the perm gen space, you'll hit: "Exception in thread "runScript" java.lang.OutOfMemoryError: PermGen space"

Monday, March 29, 2010

Installing JDeveloper 11 on OSX

Guess what, JDeveloper doesn't install out of box on a Mac... here's how to fix the JDK issue so you can at least get JDeveloper installed:

cd /System/Library/Frameworks/JavaVM.framework/Home
sudo mkdir -p jre/lib
cd jre/lib/
sudo ln -s ../../../Classes/classes.jar rt.jar

Monday, March 1, 2010

Ok break is over...

Given that railsconf 2010 (and rails 3) is on the horizon, decided it's time to get writing some rails stuff again =)

Of course that means updating the gems I haven't touched in ages.
sudo gem update --system
sudo gem update

oops... rmagick fails complaining about imagemagick... Since I installed it with macports, I figured it would be easy.
sudo port update imagemagick
Except that failed, complaining about gettext. Long story short, I didn't update macports when I upgraded to snow leopard. Easiest (if probably slowest) was to blow away macports.

sudo port -f uninstall installed

sudo port clean --work --archive all

sudo port install imagemagick

An hour or two later... imagemagick works!