How to dynamically autogenerate Java Beans from WSDL?

cxf, java, jax-ws, wsdl, wsdl2java

Solution

CXF does have a "DynamicClient" (see: http://cxf.apache.org/javadoc/latest-2.6.x/org/apache/cxf/jaxws/endpoint/dynamic/JaxWsDynamicClientFactory.html ) that can be used for this. It parses the wsdl, generated JAXB objects and compiles them, and returns a client that can be used to get the operations and types and such associated with them.

Problem

I would like to develop an application to test Web Services, which will automatically generate a JSF form using parameters from the provided WSDL. The WSDL URL is provided by user and I don't know the names of operations before parsing it. I would like the app to go through the parsed operations and its parameters, and autogenerate the appropriate Java Beans, which I will use to generate a JSF form. I have tested CXF and JAX-WS, but I think they need to know the operation names before generating Java beans. How to transparently generate Java Beans for any WSDL? Manually running `wsdl2java` is not a solution.

Original source