Showing posts with label clientgen. Show all posts
Showing posts with label clientgen. Show all posts

Tuesday, September 28, 2010

Command Line Parsing with Java

Look no further, here
http://code.google.com/p/cli-parser/

is all what you need!

Many times I wonder why such cool features are not embedded in the Java Language itself.

Friday, June 11, 2010

WebLogic 11 clientgen and Java Client for a WebLogic Web Service

after having added tons of JARs to the classpath, I still get this error message:

java.lang.IllegalAccessError: tried to access class weblogic/wsee/jaxws/WLSContainer$WLSContainerResolver$1 from class weblogic/wsee/jaxws/WLSContainer$WLSContainerResolver

I give up hopes on clientgen.  I will simply use Axis2 libraries.


http://ws.apache.org/axis2/1_1_1/userguide-creatingclients.html

to get the xmlbeans data binding just run:

cd C:\apps\axis2-1.5.1\bin
wsdl2java.bat -d xmlbeans -uri C:/temp/GEOOSBService.WSDL

Remember first to set AXIS2_HOME to C:\apps\axis2-1.5.1

actually the advantage of using Axis databinding option (no -d xmlbeans, use the default) is that you have only 2 Java files to use:
GeoOsbServiceCallbackHandler.java and
GeoOsbServiceStub.java

I like simplicity!

Wednesday, May 19, 2010

WebLogic: building a Java client for a Web Service

1) create a WebLogic Web Service project - separate from the WebService service project

2) copy the C:\beaosb\wlserver_10.3\server\lib\wseeclient.zip to the lib directory and UNZIP IT (huge amount of jars there)

3) add all the jars to the project classpath

4) add C:\beaosb\modules\org.apache.ant_1.6.5\lib\ant.jar  to the classpath

5) copy the WSDL, run the clientgen wizard, generate the client jar and add it to the classpath


6) write this kind of code:

        CompanyDBWSService service = new CompanyDBWSService();
        Company company = new Company();
        company.setId(1234L);
        company.setName("PierreIsAPig");
        company.setCreationDate(1961);
        service.getCompanyDBWSSoapPort().insertCompany(company);


here are the official instructions:

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webserv/client.html#wp229351

see also this thread

http://forums.oracle.com/forums/thread.jspa?threadID=723357&tstart=-1

Monday, February 22, 2010

Clientgen and XMLBeans

I was using clientgen to generate a Java Client for our WLI processes, and I was getting very frustrated at having all the Data Types  generated as JAXB-annotated POJOs - which is not particularly advantageous when you already have the same Data Types in the project as XMLBeans object.
I am particularly fond of XMLBeans and I don't see why I should switch to another technology.

Well, it turns out that there is a UNDOCUMENTED (at least in 9.2) flag to have clientgen use XMLBeans:

http://forums.oracle.com/forums/thread.jspa?messageID=3008420


<clientgen
wsdl="SimpleClientImplService.wsdl"
destDir="${clientclasses.dir}"
JaxRPCWrappedArrayStyle="false"
typeFamily="XMLBEANS_APACHE"
packageName="some.pagage">
</clientgen>


Some more documentation here:

http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webserv_ref/anttasks.html#wp1039270

thanks to Luciano Fiandesio for bringing this to my attention.


Anyway I have tried to make XMLBeans work inside Weblogic Workshop, no way, always NoClassDefFoundError even if I set correctly the classpath, I give up and go back to JAXB.

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.

Monday, February 8, 2010

WebLogic: invoking web services and clientgen

From your Web Service  (or JPD process), generate the WSDL (say HelloWorldSyncContract.WSDL).

In Workshop, Right Click on the WSDL, and do "clientgen": this will generate a HelloWorldSyncContract.jar file.

Put the jar file in the lib directory of your Test project.

You are now ready to code tests.... once you sort our all the NoClassDefFound that you will get... you need to add some 10 modules to your classpath:

Here is a list of modules:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Oracle WebLogic Server v10.3 JRE"/>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
    <classpathentry kind="src" path=".apt_src">
        <attributes>
            <attribute name="optional" value="true"/>
        </attributes>
    </classpathentry>
    <classpathentry kind="con" path="com.bea.workshop.wls.j2eelib/wls-commonslogging-bridge-war/exact/1.0"/>
    <classpathentry kind="lib" path="lib/CompanyDBWS.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/workshop_10.3/weblogic-beehive/lib/controls/weblogic-webservice-control.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/workshop_10.3/weblogic-beehive/lib/controls/runtime/weblogic-controls.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/org.apache.beehive_1.0.2.2/apache-beehive-svn-snapshot/lib/controls/beehive-controls.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/wlserver_10.3/server/lib/wseeclient.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.descriptor_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.descriptor.j2ee_1.1.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/glassfish.jaxws.rt_2.1.3.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.weblogic.saaj_1.3.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.xml.staxb.runtime_1.3.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.weblogic.workmanager_1.4.0.0.jar"/>
  
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.utils.classloaders_1.4.0.0.jar"/>
  
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.utils.full_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.logging_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.management.core.binding_2.3.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.management.core_2.3.0.0.jar"/>

    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.i18n_1.4.0.0.jar"/>



    <classpathentry kind="output" path="build/classes"/>
</classpath>



I have struggled with JavaClassFinder (precious tool!) to find out all these libraries.

Anyway we have 2 ways:
the JAX-WS
http://download-llnw.oracle.com/docs/cd/E12840_01/wls/docs103/webserv/client.html
and the RPC way
http://download-llnw.oracle.com/docs/cd/E12840_01/wls/docs103/webserv_rpc/client.html


You can learn from WebLogic examples file:///C:/beawli/wlserver_10.3/samples/server/docs/core/index.html


Later note: in fact WebLogic already gives you all the jars you need in the famous wseeclient.zip 

See here
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webserv/client.html#wp229351

So.... read carefully documentation before you start chasing things around...