Hi

If you'd like to do it from your custom AOP handler then one way to figure out if it is SOAP or not is by getting the current message like this :

String ct = 
PhaseInterceptorChain().getCurrentMessage().get(Message.CONTENT_TYPE)
if ("text/xml".equals(ct) || "application/xml+soap".equals(ct)) {
  // most likely SOAP, though if it text/xml then you might also want to check 
the headers like SOAP Action, etc
}
That said if you have different types of exceptions for SOAP and REST then may be there's no point in doing the above check. If MyApplicationFault were thrown in both cases then you'd need to do these additional checks

cheers, Sergey

----- Original Message ----- From: "Pydipati, Karuna" <[email protected]>
To: <[email protected]>
Sent: Friday, November 20, 2009 4:48 AM
Subject: JAXWS&JAXRS together - error handling?


Hi

I have a interface method declared as mentioned below. This is
combination of both SOAP and REST. So, client can be doing either SOAP
call or REST call. How do I know in the implementation of this method
whether the client is doing SOAP call or REST call? If there is some
clue in-side the implementation, then, I can throw either
MyApplicationFault(if it is SOAP client call) or WebApplicationException
(if it is REST call). I thought of having both MessageContext (for REST
case) and WebServiceContext(for SOAP case) annotated setters inside the
implementer class. is it a fair assumption that when in SOAP-call
MessageContext would be null OR in REST-call..WebServiceContext be null?
I read in the CXF documentation that this is not the case. The both
objects would not be null(s) for either of the case. How to solve this
riddle? I read in some other thread that I can do ExceptionMapper. I
thought of doing my own Spring AOP and handle this..if I have some clue
in implementing method whether the caller is doing SOAP call or REST
call. Any help is appreciated.

   @WebMethod
   @GET
   @Path("/{id}")
   @Consumes("*/*")
   Book getBook(@PathParam("id") @WebParam(name = "id") Long id) throws
MyApplicationFault, WebApplicationException;

Please note that the above method is throwing MyApplicationFault (for
SOAP) and WebApplicationException (for REST)


Regards

Karuna Pydipati

StubHub/eBay - Platform & Services

Phone: (415)222-8752

Email: [email protected] <mailto:[email protected]>





Reply via email to