views:

27

answers:

1

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...')

+1  A: 

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?

CtrlDot
Well, not all the statuses are error conditions, and the purist in me dislikes the idea of throwing an exception to indicate "Everything was great, but...".
Shawn D.
Almost like you would be better off returning an enum or something like that. I think returning complex objects is tough, but if they are objects of simple types, you'd be okay. I seem to remember that you have to create a data contract for the enum and then it will be placed into the wsdl. I know you are asking for a specific annotation, but I can't think of it right now.
CtrlDot
I'm giving up on this; I'll give you the full rep since you were the only one nice enough to answer. :-) Thanks.
Shawn D.