Sep 23, 2009

Generate J2SE client from WSDL using JBoss wsconsume

If you have a valid WSDL URL and need to invoke web service method(s), here is what I compiled in order to consume a WSDL in JBoss environment:

We will Use “wsconsume” utility supplied by JBoss WS (available under /bin) to generate necessary glue code and stubs/interfaces.
  1. Type-in following command on the command prompt. Make sure that you have working WSDL URL before executing following command:
    [JBOSS Path]\bin>wsconsume -k -p packageName -o targetBinDir -s TaregtSrcDir http://127.0.0.1:8080/ejbs/HelloWorld?wsdl
  2. Once you have the interfaces, you can write the client like this (you should get the classes names (service, proxy) from the generated code in targetBinDir ):
public class HelloWorldClient {
    public static void main(String[] args) {
        //Create Service
        HelloWorldService service = new HelloWorldService();

        //create proxy
        HelloWorld proxy = service.getHelloWorldPort();

        //invoke
        System.out.println(proxy.hello("hello"));
    }
   }
  • Related links:
http://myarch.com/create-jax-ws-service-in-5-minutes
http://www.mastertheboss.com/en/web-interfaces/101-jboss-web-services-part-1.html