Here's how to call a Metro-based web service from Clojure.

  1. Create and deploy a web service called "Test" with one "hello" method that takes and echoes a string (follow section 7 in the Metro Users Guide for creating a web service using NetBeans or follow section 14 for using Ant.) Just create a vanilla service (i.e., no RM, Security, etc).
  2. This example assumes the service is deployed athttp://localhost:8080/Test/TestService.
  3. Use wsimportto create the client side proxy: 
    
    $JAVA_HOME/bin/wsimport -keep -p generated.test http://localhost:8080/Test/TestService?wsdl
    
  4. Put the location of generated.text in your classpath when starting up clojure.
  5. Start up clojure and enter this function definition after its prompt 
    user> (defn hello [x]
            (let [service (generated.test.TestService.)
              port (. service getTestPort)]
          (. port hello x)))
    
    #'user/hello
    
  6. Then call it 
    user> (hello "world")
    "from SERVICE: world"
    

That's it! Enjoy

ps: What's the purpose of Lots of InsipidStupid Parenthesis? MACROS!

Technorati: clojure projectmetro glassfish netbeans wsit