Thursday, February 11, 2010

Automating clientgen from Java

package com.acme.integration.tools;

import java.io.File;
import java.util.List;

import weblogic.wsee.tools.WsBuildException;
import weblogic.wsee.tools.clientgen.jaxws.ClientGenImpl;

public class ClientGenTool {
    public final static String wls_hostname = "10.10.10.20";
    public final static String wls_port = "7001";
    public final static String process_name = "/processes/GetPrepaidAccountBalanceProcess";
    public final static String clientclass_dir = "output/clientclass";
   
    public static void main(String[] args) throws WsBuildException {
        ClientGenTool clientGenTool = new ClientGenTool();
        clientGenTool.clientgen();
    }
   
   
    public void clientgen() throws WsBuildException {
        String wsdl = "http://" + wls_hostname + ":" + wls_port + "/ACME_INTEG_WEB" + process_name + ".jpd?WSDL";
        System.out.println("using wsdl " + wsdl);
        File destDir = new File(clientclass_dir);
        String packageName = "examples.webservices" + process_name.replace("/", ".");

        ClientGenImpl cgi = new ClientGenImpl();
        cgi.setWsdl(wsdl);
        cgi.setDestDir(destDir);
        cgi.setPackageName(packageName);
        cgi.execute();
       
    }
   
}

this will generate the client classes.... it makes our life a lot easier when you have hundreds of Web Services to test....

remember to add tools.jar to the classpath, otherwise the javac compiler will not work.

No comments: