Combining SOAP (JAX-WS) and REST(JAX-RS) for same method

View: New views
2 Messages — Rating Filter:   Alert me  

Combining SOAP (JAX-WS) and REST(JAX-RS) for same method

by Pydipati, Karuna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
 
Is it possible to combine both SOAP and REST pointing to same
interface/class in java-first approach. It seems it is possible by
looking at this documentation.
(http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Understandingthebasics).
If so, how are we dealing with SOAP header in REST world.
 
For example, here is SOAP signature. How does it work in REST way? I
mean..how to modify this signature to make it work for both REST and
SOAP at the same time (just using annotations). Please remember that it
has AuthHeader. How does it behave in REST call? Thanks in advance
 
 @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
 @WebResult(targetNamespace = "http://order.api.xxx.com/", partName =
"parameters", name = "orderResponse")
 @WebMethod
 public com.xxx.api.order.OrderResponse getOrder(
   @WebParam(targetNamespace = "http://order.api.xxx.com/", partName =
"parameters", name = "orderRequest")
   com.xxx.api.order.OrderRequest parameters,
   @WebParam(targetNamespace = "http://order.api.xxx.com/",
name="AuthHeader", header=true, partName="AuthHeader")
   com.xxx.webservices.common.AuthHeader authHeader) throws XXXFault;

 

Regards

Karuna Pydipati

StubHub/eBay - Platform & Services

Phone: (415)222-8752

Email: kpydipati@... <mailto:kpydipati@...>

 

 

Re: Combining SOAP (JAX-WS) and REST(JAX-RS) for same method

by Sergey Beryozkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

In SOAP case one can have a structured/complex SOAP (AuthHeader) header emdedded inside an envelope, so the question is whether you
can, when doing a non-SOAP HTTP invocation, convey the same information by using a custom HTTP AuthHeader. Assuming it is possible
to do in you case, for ex, by doing :

AuthHeader: a=b, c=d

then the way to go in this specific case would be to do (just stripping some of the JAXES annotations for brevity) :

 @WebMethod
 public com.xxx.api.order.OrderResponse getOrder(
   @WebParam(targetNamespace = "http://order.api.xxx.com/", partName ="parameters", name = "orderRequest")
   com.xxx.api.order.OrderRequest parameters,
   @WebParam(targetNamespace = "http://order.api.xxx.com/",name="AuthHeader", header=true, partName="AuthHeader")
   @HttpHeader("AuthHeader")
   com.xxx.webservices.common.AuthHeader authHeader) throws XXXFault;


Note the JAXRS @HttpHeader("AuthHeader").
Next register a custom provider (same way as you register custom readers/writers)
which implements ParametertHandler<com.xxx.webservices.common.AuthHeader> and in its fromString(String value) parse
an "a=b, c=d" sequence, and return an instance of AuthHeader...

I think it will work, can you give it a try please ?

Another option is to update com.xxx.webservices.common.AuthHeader with
public static AuthHeader valueOf(String str)

but it might be a bit more intrusive...

Hope it helps, Sergey


Hi

Is it possible to combine both SOAP and REST pointing to same
interface/class in java-first approach. It seems it is possible by
looking at this documentation.
(http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Understandingthebasics).
If so, how are we dealing with SOAP header in REST world.

For example, here is SOAP signature. How does it work in REST way? I
mean..how to modify this signature to make it work for both REST and
SOAP at the same time (just using annotations). Please remember that it
has AuthHeader. How does it behave in REST call? Thanks in advance

 @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
 @WebResult(targetNamespace = "http://order.api.xxx.com/", partName =
"parameters", name = "orderResponse")
 @WebMethod
 public com.xxx.api.order.OrderResponse getOrder(
   @WebParam(targetNamespace = "http://order.api.xxx.com/", partName =
"parameters", name = "orderRequest")
   com.xxx.api.order.OrderRequest parameters,
   @WebParam(targetNamespace = "http://order.api.xxx.com/",
name="AuthHeader", header=true, partName="AuthHeader")
   com.xxx.webservices.common.AuthHeader authHeader) throws XXXFault;



Regards

Karuna Pydipati

StubHub/eBay - Platform & Services

Phone: (415)222-8752

Email: kpydipati@... <mailto:kpydipati@...>