6

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.

niutech
  • 28,923
  • 15
  • 96
  • 106

2 Answers2

5

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.

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37
  • I've used CXF DynamicClient and it worked just fine: `JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client c = dcf.createClient(url); Endpoint e = c.getEndpoint(); ServiceInfo si = endpoint.getService().getServiceInfos().get(0); BindingInfo bi = si.getBindings().get(0); BindingOperationInfo boi : bi.getOperations().get(0);` – niutech Jun 18 '12 at 22:12
  • I tried with the code given above but not working. it complains about .get(0) for BindingInfo and BindingOperationInfo. could you please please place the working code here. Thanks – Motilal Dec 23 '15 at 11:10
-2

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

Qwerky
  • 18,217
  • 6
  • 44
  • 80