cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liu, Jervis" <j...@iona.com>
Subject RE: Code first tool proposal
Date Wed, 25 Jul 2007 09:58:20 GMT
Cool! This is definitely something we want. Only thing confused me is, same as James, how this
java2cs (we probably want a better name, such as java2webservices, but lets use this name
for the following discussion) relates to java2wsdl, when I should use java2wsdl and when I
use java2cs. java2wsdl and java2cs will have a lot functionalities overlapped, which is fine,
users are free to choose different tools to achieve same need, but to avoid any confusions,
I think we really need to take a closer look and makes it  clear on how these tools are supposed
to be used. To get started, I would like to identify our use cases/scenarios and exam how
java2cs and java2wsdl can be used under each scenario. 
 
The use case for java2cs:
 
For a code-first approach, I will start with three things normally: a bunch of  POJOs or type
classes (eg, JAXB type class, object factory etc); business interface (plain java or JAX-WS
SEI); impl class (plain java or Jax-ws impl class). What I want is quickly turning those classes
into a runnable or deployable web services bundle. During this process, I may or may not care
about the WSDL. 
 
In this case, a usage of java2cs looks like below is enough for me:
 
java2cs -cp -client -server -frontend -databinding –binding (i.e, xml binding or soap binding)
–wsdl -spring -ant 
 
I can see the how much benefit I can get from using java2cs. Run one command, then everything
is ready to go. BTW, I think the generation of server main class is exclusive to the generation
of spring configuration. If I am going to run my cxf web serivce in a spring container, I
don’t really need java main class.
 
The use case for java2wsdl:
 
This is where the headache comes from. With the presence of javatocs, why I still want to
use java2wsdl? Generating a WSDL does not do any good to me anyway, at the end of day, it
is the deployable or runnable service what I really want. The reason why javatowsdl is there
is because without java2cs, to do a code-first development I have to call ava2wsdl first,
then I need to either write server main class or spring config by myself, or I need to run
wsdl2java based on generated WSDL. Shouldn’t we merge  java2cs and javatowsdl into one tool,
so javatowsdl essentially is equal to java2cs –wsdl? I understand javatowsdl has a lot of
extras flags that allow you to customize WSDL generation, but we should have no problem to
include these flags in java2cs as well, if the ultimate goal of javatocs is to allow you generate
web services in one go (i.e., as simple as possible) and at the same time allow you to customize
how your web service is published (i.e., as powerful as possible). Unless someone can identify
a use case of java2wsdl that is different from code-first, I would say it is justified to
merge javatowsdl into java2cs. Thoughts?

Cheers,
Jervis






-----Original Message-----
From: James Mao [mailto:james.mao@iona.com]
Sent: 2007?7?25? 11:26
To: cxf-dev@incubator.apache.org
Subject: Re: Code first tool proposal


Excellent work, Jim,

If you can also comment on the relationship between the java2wsdl and
java2cs, that will be great
IMHO, the java2wsdl does support the jaxws, and simple frontend, but
it's only generate the wsdl, is it the duplicate function in the java2cs,
Or is it possible to extend the java2wsdl (we need to find a better name
for it)
Or java2cs will call into the java2wsdl to generate the wsdl files, and
associate the artifacts (like the beans/binding files in case of jaxws)

And the java2cs should also generate the configuration files, right?
(spring, servlet etc.), and also we need have the ant tasks, so
generating artifacts, and then compile, deploy, all in one command.

All in all, looks a good plan :)

James

> Hi All ,
>
> Here is my proposal for implementing a code first tool to generate
> client ,server side code and wsdl . With this tool , user can more
> easily deploy a service with java class in cxf.
> If this is OK, I will start on writing this tool.
> Goal
> ----------
> 1. Generate jaxws frontend client server code and wsdl from Jaxws
> conformed classes
> 2. Generate simple frontend client server code and wsdl from Pojo
> class . Tool can generate and compile interface class or impl class
> the server and client side needed
> from the user provided classes.
>
> Tool Description
> -----------
> Tool Name : java2cs
> Description : takes a user defined class to generate jaxws or simple
> frontend client and server side code
> Options : -cp classpath to load the user defined classes
> -server generate server side code only, if client and server is not
> specified , both client and server code will be generated
> -client generate client side code only
> -frontend jaxws or simple , default is simple frontend. which control
> to generate jaxws and simple style server and client
> -databinding jaxb or aegis databinding. jaxws frontend will use jaxb
> databinding and simple frontend will use aegis databinding by default .
> -wsdl control to generate wsdl.
> class the full class name used to generate client and server
>
> Generated Code Sample
> --------------------------
> 1. jaxws frontend.
>
> Server code :
> =========
> public class Server {
> protected Server() throws Exception {
> System.out.println("Starting Server");
> Object implementor = new GreeterImpl();
> String address = "http://localhost:9000/SoapContext/SoapPort";
> Endpoint.publish(address, implementor);
> }
>
> public static void main(String args[]) throws Exception {
> new Server();
> System.out.println("Server ready...");
> Thread.sleep(5 * 60 * 1000);
> System.out.println("Server exiting");
> System.exit(0);
> }
> }
>
> Client code :
> ========
> ...
> SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
> Greeter port = ss.getSoapPort(); port.sayHi();
> ...............
>
> 2. simple frontend :
> Server code
> =========
> ServerFactoryBean svrBean = new ServerFactoryBean();
> svrBean.setBus(CXFBusFactory.getDefaultBus());
> svrBean.setAddress("http://localhost:8080/Hello");
> svrBean.setTransportId("http://schemas.xmlsoap.org/wsdl/http/");
> svrBean.setBindingId("http://schemas.xmlsoap.org/soap/");
> svrBean.setServiceBean(new GreeterImpl());
> svrBean.getServiceFactory().setDataBinding(new AegisDatabinding());
> svrBean.setStart(true);
> svrBean.create();
> System.out.println("Server started");
>
> Client code :
> ========
> ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
> ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
> clientBean.setAddress("http://localhost:8088/Hello");
> clientBean.setBus(CXFBusFactory.getDefaultBus());
> clientBean.setTransportId("http://schemas.xmlsoap.org/wsdl/http/");
> clientBean.setServiceClass(Greeter.class);
> proxyFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
> Greeter client = (Greeter) proxyFactory.create();
>
> Any thoughts and directions would be appreciated !
>
> Thanks
>
> Jim

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Mime
View raw message