|
Replies:
5
-
Last Post:
Apr 7, 2009 1:43 PM
by: mahrer
|
|
|
|
|
|
|
WSDL first - wsgen not creating classes from defined WSDL schema types
Posted:
Mar 24, 2009 3:45 AM
|
|
|
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?
|
|
|
|
|
|
|
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted:
Mar 24, 2009 10:58 AM
in response to: mahrer
|
|
|
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.
|
|
|
|
|
|
|
|
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted:
Apr 6, 2009 1:48 AM
in response to: ramapulavarthi
|
|
|
> 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!
|
|
|
|
|
|
|
|
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted:
Apr 6, 2009 10:14 AM
in response to: mahrer
|
|
|
> 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.
|
|
|
|
|
|
|
|
Re: WSDL first - wsgen not creating classes from defined WSDL schema types
Posted:
Apr 7, 2009 1:43 PM
in response to: ramapulavarthi
|
|
|
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)
|
|
|
|
|