niutech
niutech

Reputation: 29962

How to dynamically autogenerate Java Beans from WSDL?

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.

Upvotes: 6

Views: 3748

Answers (2)

Daniel Kulp
Daniel Kulp

Reputation: 14607

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.

Upvotes: 5

Qwerky
Qwerky

Reputation: 18445

If you are using Maven (and you should be) you can use the CXF codegen plugin to generate classes from the WSDL. There's an example on my blog;

http://qwerky-qwerky.blogspot.co.uk/2011/12/programming-without-programming-1.html

Upvotes: -2

Related Questions