Deprecated Garbage Collections – Kenny Lee Chee Wei

A truckload of garbage by Kenny Lee Chee Wei

Groovy Web Service Client (GroovyWS)

with 5 comments

Here’s 2 examples of how simple groovy web service clients can be. You will need to download a groovy lib jar from the GroovyWS Home Site. Basically it just creates the classes dynamically on-the-fly instead of creating stubs.

1. CurrencyConvertor

import groovyx.net.ws.WSClient
proxy = new WSClient("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", this.class.classLoader)
//'USD', 'EUR', 'CAD', 'GBP', 'AUD', 'SGD'
rate = proxy.ConversionRate('SGD','USD')
print rate

2. Stock Quote

import groovyx.net.ws.WSClient
proxy = new WSClient("http://www.webservicex.net/stockquote.asmx?WSDL", this.class.classLoader)
quote = proxy.GetQuote('GOOG')
print quote

Read Geertjan’s groovy_web_service for more info (Swing).

Read the official Groovy Web Service Doc for more info (Groovy WS) .

Advertisements

Written by kennii

January 2, 2008 at 8:03 am

Posted in Groovy

5 Responses

Subscribe to comments with RSS.

  1. That is exactly how complex a client should be. Java web service clients have been too complex in the past. It doesn’t help that in the past vendors (I’m looking at you BEA) always liked to pile on their cruft to make life (cough, cough) easier 🙂

    Scott

    July 18, 2008 at 5:28 pm

    • Let’s see you some message level encryption via WS-Security used on this call and see how simple it remains.

      Jake

      June 16, 2009 at 11:36 am

  2. these are just toy programs .

    jignesh

    January 7, 2009 at 9:17 am

  3. Following script is generated with SoamMoa
    See soamoa.org

    /* Generated GroovyWS Script by SoaMoa, :ridvan at Thu Oct 08 23:14:13 CEST 2009 */

    import groovyx.net.ws.WSClient

    def proxy = new WSClient(“http://www.webservicex.net/CurrencyConvertor.asmx?WSDL”, this.class.classLoader)
    proxy.create()
    def conversionRateResponse = proxy.ConversionRate(‘USD’, ‘EUR’)
    assert (conversionRateResponse == 0.676)

    soamoa-fan

    October 8, 2009 at 9:16 pm

  4. The examples did not work by exactly copy/pasting and running them.
    I had to add the line
    proxy.initialize()
    after creating the proxy.

    Still got WARNING: Using SOAP version: 1.1 but got the reply.

    Question:
    How can I set wait timeouts to the proxy?

    Vijay

    January 7, 2010 at 2:40 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: