The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » Metro and JAXB

Thread: WSDL first - wsgen not creating classes from defined WSDL schema types

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is not answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 5 - Last Post: Apr 7, 2009 1:43 PM by: mahrer
mahrer

Posts: 10
WSDL first - wsgen not creating classes from defined WSDL schema types
Posted: Mar 24, 2009 3:45 AM
 
  Click to reply to this thread Reply

I'm doing WSLD first development and using wsgen to process the @WebService / @WebMethod annotated endpoint.
This produces the request / response wrapper classes but no JAXB artifacts like the types declared by the schema, fault types etc.
Do I need to run a JAXB compiler manually in order to get these artifacts??? For example the service endpoint needs to throw the exception that has been defined to indicate a fault so it needs the Java class for this exception.

At the client side the wsimport tool is run which creates the all the types as described by the WSDL so why not wsgen?

ramapulavarthi

Posts: 525
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted: Mar 24, 2009 10:58 AM   in response to: mahrer
 
  Click to reply to this thread Reply

JAX-WS ( with the help of JAXB) will take care of generating the required Java classes, in this case wrappers. JAXB uses default mapping rules for mapping standard types and user defined types as long as they follow the jaxb bean conventions. Thats why you are not seeing those classes. With JAX-WS 2.1.5 and later these wrappers are generated dynamically.

Are you using -wsdl option of wsgen to generate the wsdl? If so, you would notice that the JAX-WS generates the correct type definitions for the beans used in your web service in the generated schema.

mahrer

Posts: 10
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted: Apr 6, 2009 1:48 AM   in response to: ramapulavarthi
 
  Click to reply to this thread Reply

> JAX-WS ( with the help of JAXB) will take care of
> generating the required Java classes, in this case
> wrappers. JAXB uses default mapping rules for mapping
> standard types and user defined types as long as they
> follow the jaxb bean conventions. Thats why you are
> not seeing those classes. With JAX-WS 2.1.5 and later
> these wrappers are generated dynamically.
>

Ok the wrappers are created dynamically but for implementing the endpoint the types from the schema (types are bold) are required too! So the implementation needs some type for instantiating a result to give an example.

Some example:
@WebMethod(operationName = "getCustomer[")
@WebResult(name = "customer")

public Customer getCustomer[(@WebParam(name = "id")
String id) throws InvalidIdException {
assert id != null;

try {
... do some calculation
} catch (IllegalArgumentException e) {
final InvalidIdFaultDetailType faultDetail = new InvalidIdFaultDetailType();
faultDetail.setId(e.getMessage());
throw new InvalidIdException(e.getMessage(), faultDetail);
}
return new Customer(...);
}

Customer is a type specified by the XML schema for which classes should be generated.
So basically I'm starting with no Java code and only a WSDL and a schema!

Meanwhile I have worked around by also running the wsimport tool for the service implementation - But is this how it is supposed to work???

> Are you using -wsdl option of wsgen to generate the
> wsdl? If so, you would notice that the JAX-WS
> generates the correct type definitions for the beans
> used in your web service in the generated schema.

Why would I use this option as with contract first I already start off with a WSDL!

jitu

Posts: 733
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted: Apr 6, 2009 10:14 AM   in response to: mahrer
 
  Click to reply to this thread Reply

> Meanwhile I have worked around by also running the
> wsimport tool for the service implementation - But is
> this how it is supposed to work???

For wsdl first, you just use wsimport for both client service implementation. No wsgen in this case.

ramapulavarthi

Posts: 525
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted: Apr 6, 2009 11:24 AM   in response to: mahrer
 
  Click to reply to this thread Reply

I was assuming you were using wsgen and working on server-side.
See https://jax-ws.dev.java.net/nonav/2.1.5/docs/jaxws-tools.html#mozTocId344067 that suggests which Tool to use.

mahrer

Posts: 10
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted: Apr 7, 2009 1:43 PM   in response to: ramapulavarthi
 
  Click to reply to this thread Reply

Yes, I am working on the server side (the service implementation) and I'm using wsgen. But as wsgen is NOT creating all of the classes defined by the XSD I am also running wsimport (which is weird anyway but at least generates the missing classes)




 XML java.net RSS