I have a webservice that I’m using JAX-WS annotations to generate the WSDL & associated client code (writing both ends, just using JAX-WS for the transport).
I’ve got a method that can have different return values depending on the state of the request,
@WebMethod
public int uploadResults(
@WebParam(name="authentication") ServiceAuth auth,
@WebParam(name="mimeType") String mimeType,
@WebParam(name="data") byte [] dataBlock )
{
// ... omitted.
and some return values are also defined in the class.
public static final int STATUS_OK = 0;
public static final int STATUS_ERROR = 1;
public static final int STATUS_AUTH_FAILURE = 2;
... etc.
After using wsgen to generate the WSDL, and wsimport for the client-side code, there aren’t any references anywhere to these constants. Ideally, I’d rather not define them in two spots, and they don’t share a source tree, so it’s also a little awkward to define them in a common location.
So, my question is:
Is there an annotation I could put on each of the declarations so that something would be written with the identifier into the WSDL and subsequently, a similar constant defined in the client-side classes generated by wsimport?
(p.s. I’d also appreciate any comments on ‘you’re doing it wrong, return status this way instead…’)
Wouldn’t you be better off trying to pass exceptions down the wire then coming up with a custom way that needs to be defined in two areas?