tags:

views:

1203

answers:

3

Hi. I have a package with "logic" classes(like CheckAuthenticationDataLogic.java, GetVocabulariesLogic.java). And another class - ApiService.java is used to generate wsdl. ApiService.java is full of methods like this:

/**
   * Check authentication data.
   * @param contractNumber - number of contract.
   * @param msisdn - msisdn.
   * @param superPassword - super password.
   * @return result of authentication.
   */
  @WebMethod
  @WebResult(name = "result")
  public CheckAuthenticationDataResult checkAuthenticationData(@WebParam(name = "contractNumber")
                                                               final String contractNumber,
                                                               @WebParam(name = "msisdn")
                                                               final String msisdn,
                                                               @WebParam(name = "superPassword")
                                                               final String superPassword) {
    return runLogic(new CheckAuthenticationDataLogic(contractNumber, msisdn, superPassword));
  }

As you see it's just a proxy methods... So i want to avoid doing same work twice and generate WSDL right from logic classes without writing ApiService.java. Any tool or library for this purpose exists ?

A: 

The Metro (https://metro.dev.java.net/) web service stack provides a tool (wsgen) to generate WSDL from annotated Java.

Edit: Changed link presentation.

Frank Grimm
You don't need Metro (Metro = JAX-WS RI + WSIT/Tango), you only need JAX-WS RI which is included in Java 6. So if you are using Java 6, you actually don't need anything.
Pascal Thivent
@Pascal Thivent: You are absolutely right. Though, I think that Metro is usually more up-to-date than the JAX-WS RI provided by JSE.
Frank Grimm
Well, the JDK 6 Update release 14 has JAX-WS 2.1.6 RI which is pretty decent. But indeed, Metro 1.5 includes JAX-WS 2.1.7 (which is considered as a minor release, see http://weblogs.java.net/blog/2009/04/21/jax-ws-ri-217metro-15-released). However, if you want to use JAX-WS RI 2.1.7, you can download it from https://jax-ws.dev.java.net, you still don't need Metro. But honestly, I wouldn't bother playing with the endorsed directory mechanism.
Pascal Thivent
+1  A: 

The wsgen tool generates JAX-WS portable artifacts used in JAX-WS web services. Note that you do not have to generate WSDL at the development time as JAXWS runtime will automatically generate a WSDL for you when you deploy your service.

You might want to check the JAX-WS RI documentation and especially the samples (pay a special attention to the fromjava sample).

Pascal Thivent
i have an error "Exception in thread "main" java.lang.NoClassDefFoundError" and it occurs because this class is placed not in the classpath but in remote library(libraries are placed just in another folder). How can i include this libraries to my classpath ?
Olexandr
wsgen -wsdl:Xsoap1.2 -extension -d testGen -cp /home/vidocq/workspace/ws-crp/build/output/eclipse-classes com.crp.logic.CheckAuthenticationDataLogic
Olexandr
What error do you get when running `wsgen` with `-cp`? Please update your question with details on your project configuration (where are sources located) and the trace.
Pascal Thivent
A: 

Axis2 is another alternative, specifically the java2wsdl command/plugin

puug