Thanks Sergey for the extensive explanation.

For now excluding the property is my biggest concern. Please let me know if 
there is some solution for the same.

Please see my comments inline....

Regards,
Abhishek

-----Original Message-----
From: Sergey Beryozkin [mailto:sbery...@progress.com] 
Sent: Thursday, February 18, 2010 5:26 PM
To: users@cxf.apache.org
Cc: Sharma, Abhishek
Subject: Re: how to send Nested object in RESTful webservice

Hi, thanks for the clarification, lets move the discussion back to the users 
list...

Please see my comments inline...

cheers, Sergey

----- Original Message ----- 
From: Sharma, Abhishek
To: Sergey Beryozkin
Sent: Thursday, February 18, 2010 8:10 AM
Subject: RE: how to send Nested object in RESTful webservice


Yes I've requirements like this:

public Emsnamespace add(@FormParam("") Emsnamespace namespace, @FormParam("") 
Product product)

> S.B : I'm not sure having multiple aggregating @FormParam("") parameters will 
> work. It might work but I'm not really sure. The 
> idea of having a @FormParam("") (or QueryParam(""), etc) is to have all the 
> available name/value pairs in the request body (for 
> FormParam) or in the URI (for QueryParam or PathParam) injected into a bean 
> like Emsnamespace or Product which can have nested 
> types if needed but the important thing is that as far as the request body or 
> uri is concerned is is still name/value pairs that 
> are expected (exception : templateVarName to corresponding captured value 
> pairs in case of PathParam("")).

[A.S]:  Multiple @FormParam works fine and is not a problem till the time there 
is no ambiguity on param names. I feel that's fine as REST wants name-value 
params in request so it's my web methods which are not designed considering 
unique param name so probably won't work with REST. So its violating REST basic 
principle and CXF or any other framework can't help.


Problem 1
Now the problem is the WADL generated have two namespaceName param from both 
the POJOs resulting in injection error. This type of 
issues are also causing cyclic dependency error in some of the web methods.

> S.B : When you say an injection error occurs, what do you mean ? Do you have 
> SOAP UI invoking ? What exactly is happening ? Can 
> you capture what is being posted on the wire ?


[A.S] I was using Fiddler This is the error I was getting: 
Payload: Method getNamespaceName injection failure


> S.B : Note, given the above, having multiple @FormParam("") will probably 
> work after all provided you are actually doing a *form 
> submission*, that is you have a request body containing a sequence of 
> name/value pairs. The fact that the WADL fragment shows few 
> duplicates in this case should not make a difference,  Emsnamespace should 
> get its setters invoked and Product have its setters 
> invoked. You'd probably be better off trying to have a single complex 
> FormParam("") parameter which will accumulate all the form 
> data and then internally populate Emsnamespace and Product.

I want to suppress the namespaceName in Product by using property like 
@IgnoreProperty(Worked for WSDL).

> S.B : In WADL it is either JAXBContext which can be used to generate a schema 
> or starting from 2.2.7-SNAPSHOT, one can point to 
> the existing schemas which can be inlined or linked to. I'm not planning to 
> do some manual schema generation so that cretain 
> properties get excluded in the schema.

By the way, the types which you use are not qualified so the generated schema 
is a bit broken. Aegis will create a custom namespace 
but it is not that WADLGenerator will do...I think I might try extending 
WADLGenerator to ask ProviderFactory for a provider capable 
of handling XML and then delegate to them to generate the schema...So then 
AegisProvider can get extended a bit and have the schema 
generated...

Also, as far as WADL and FormParam("") is concerned, it might make sense to 
have certain properties excluded.


[A.S] for now excluding the property is my biggest concern. As for sending a 
single object inside an object URL like (see emsnamespace.namespaceId):

/catalogServiceRest/catalogServiceRest/add?productname=Abhishek&version=1.1&emsnamespace.namespaceId=1

Works for me. So the nested object is something working in the manner as we 
write query in hibernate query language. 


Problem 2
I also have requirement to set collection of child elements in a request. For 
e.g. see the Collection of product inside namespace. 
WADL says products has to be sent as a query parameter. I don't know how to 
send this nested collection as a query parameter in case 
of REST.

> S.B. FormParams get translated to parameters of type 'query'. Do you really 
> need @FormParams after all ?

[A.S] I will do more trial on this as I am able to run One2One objects in HQL 
like style and will try for collections. Will update if I find some solution.


Thanks
Abhishek

WADL Snippet:

           <xs:complexType name="emsnamespace">
   <xs:sequence>
  <xs:element name="deployed" type="xs:boolean" />
  <xs:element maxOccurs="unbounded" minOccurs="0" name="featureSets" 
nillable="true" type="featureSet" />
  <xs:element maxOccurs="unbounded" minOccurs="0" name="features" 
nillable="true" type="feature" />
  <xs:element minOccurs="0" name="namespaceDescription" type="xs:string" />
  <xs:element name="namespaceId" type="xs:int" />
  <xs:element minOccurs="0" name="namespaceName" type="xs:string" />
  <xs:element maxOccurs="unbounded" minOccurs="0" name="products" 
nillable="true" type="product" />
  <xs:element maxOccurs="unbounded" minOccurs="0" name="suites" nillable="true" 
type="suite" />
  </xs:sequence>
  </xs:complexType>


- <resource path="/add2">
- <method name="POST">
- <request>
- <representation mediaType="application/json">
  <param name="namespacename" style="query" type="xs:string" />
  <param name="features" style="query" />
  <param name="namespaceid" style="query" type="xs:int" />
  <param name="featuresets" style="query" />
  <param name="products" style="query" />
  <param name="suites" style="query" />
  <param name="namespacedescription" style="query" type="xs:string" />
  <param name="version" style="query" type="xs:string" />
  <param name="emsnamespace" style="query" />
  <param name="namespacename" style="query" type="xs:string" />
  <param name="features" style="query" />
  <param name="productid" style="query" type="xs:int" />
  <param name="featuresets" style="query" />
  <param name="productdescription" style="query" type="xs:string" />
  <param name="suites" style="query" />
  <param name="productname" style="query" type="xs:string" />
  <param name="lifecyclestage" style="query" type="xs:string" />
  <param name="entitlementitems" style="query" />
  <param name="entitlementlicensemodel" style="query" />
  </representation>
  </request>
- <response>
  <representation mediaType="application/json" />
  <representation mediaType="application/xml" />
  </response>
  </method>
  </resource>




WSDL SNIPPET:

-                 <xsd:complexType name="Emsnamespace">
  <xsd:sequence>
  <xsd:element minOccurs="0" name="namespaceDescription" nillable="true" 
type="xsd:string" />
  <xsd:element minOccurs="0" name="namespaceId" type="xsd:int" />
  <xsd:element minOccurs="0" name="namespaceName" nillable="true" 
type="xsd:string" />
  </xsd:sequence>
  </xsd:complexType>


-----Original Message-----
From: Sergey Beryozkin [mailto:sbery...@progress.com]
Sent: Wednesday, February 17, 2010 4:50 PM
To: Sharma, Abhishek
Subject: Re: how to send Nested object in RESTful webservice

Hi

do you have

@FormParam("") Product or @FormParam("") Emsnamespace

in one of your resource methods ?

cheers, Sergey

----- Original Message ----- 
From: "Sharma, Abhishek" <abhishek.sha...@safenet-inc.com>
To: "Sergey Beryozkin" <sbery...@progress.com>
Sent: Wednesday, February 17, 2010 11:16 AM
Subject: RE: how to send Nested object in RESTful webservice


Hi Sergey,


Attached are the two files Emsnamespace and Product.

import org.apache.cxf.aegis.type.java5.IgnoreProperty;

property over a getter method removes the property from being exposed from XSD 
in WSDL.

Thanks
Abhishek

-----Original Message-----
From: Sergey Beryozkin [mailto:sbery...@progress.com]
Sent: Wednesday, February 17, 2010 4:38 PM
To: users@cxf.apache.org
Subject: Re: how to send Nested object in RESTful webservice

Thanks, can you actually send the actual class (Employee + Manager) (directly 
to me) ?

What is the @IgnoreProperty ? I've never heard of it, how do you use it ?
Regarding the exceptions handling :
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-Exceptionhandling

cheers, Sergey
----- Original Message ----- 
From: "Sharma, Abhishek" <abhishek.sha...@safenet-inc.com>
To: <users@cxf.apache.org>
Sent: Wednesday, February 17, 2010 10:59 AM
Subject: RE: how to send Nested object in RESTful webservice


Thanks Sergey for prompt reply

I changed the name of objects from

Product to Employee
and Namespace to Manager, in order to clearly convey my problem.

I was able to run the code with emsnamespace.namespaceId=5 as query param.

I've attached the WADL file. Also request you to please answer the remaining 
questions as well.
Also how can I send a collection in request param?


Thanks
Abhishek



-----Original Message-----
From: Sergey Beryozkin [mailto:sbery...@progress.com]
Sent: Wednesday, February 17, 2010 4:19 PM
To: users@cxf.apache.org
Subject: Re: how to send Nested object in RESTful webservice

Hi

Can you please post a sample resource class and this Employee object ?
@FormParams get translated to WADL parameters of type 'query'...FormParam("") 
should result in individual Employee properties such
as 'manager' being listed as parameters, but I'd like to 'manager' actually 
refers to another complex object or not...

cheers, Sergey

----- Original Message ----- 
From: "Sharma, Abhishek" <abhishek.sha...@safenet-inc.com>
To: <users@cxf.apache.org>
Sent: Wednesday, February 17, 2010 10:13 AM
Subject: how to send Nested object in RESTful webservice


I am planning to use CXF as my Webservice development framework. The java code 
is already written using spring and hibernate. The
requirement is to expose the service layer in Model as web service and their 
method as web methods in probably both SOAP and REST.

As a proof of concept I found CXF to work excellently with my application but 
I've still some open issues/questions:


Questions specific to RESTful web services:


 1.  We have @IgnoreProperty for SOAP based services what is the corresponding 
property for RESTful mode?
 2.  How to send Nested object in REST?

Details: I've to add an employee which has a @ManyToOne relationship with the 
manager object. Now WADl says
<param name="manager" style="query" />.

How can I send the entire object as query parameter? I've used 
add(@FormParam("") Employee employee) web method to publish.

Or  Do I need to put any annotation over getManager() in my Employee pojo?


 1.  How to do exception handling for REST like we have SOAPFault in soap based 
webservices


Question specific to General design:

In my web methods I am passing entire object while search/update. For now code 
is using only a few values inside the object and
ignoring the rest. What should be the behavior in case of webservice as the 
client might pass values in request which are actually
ignored by the web method. For this I just want to know what standard web 
service architecture recommends?

Thanks for help

Regards,
Abhishek






The information contained in this electronic mail transmission
may be privileged and confidential, and therefore, protected
from disclosure. If you have received this communication in
error, please notify us immediately by replying to this
message and deleting it from your computer without copying
or disclosing it.

=


The information contained in this electronic mail transmission
may be privileged and confidential, and therefore, protected
from disclosure. If you have received this communication in
error, please notify us immediately by replying to this
message and deleting it from your computer without copying
or disclosing it.



The information contained in this electronic mail transmission
may be privileged and confidential, and therefore, protected
from disclosure. If you have received this communication in
error, please notify us immediately by replying to this
message and deleting it from your computer without copying
or disclosing it.


The information contained in this electronic mail transmission
may be privileged and confidential, and therefore, protected
from disclosure. If you have received this communication in
error, please notify us immediately by replying to this
message and deleting it from your computer without copying
or disclosing it. 

The information contained in this electronic mail transmission 
may be privileged and confidential, and therefore, protected 
from disclosure. If you have received this communication in 
error, please notify us immediately by replying to this 
message and deleting it from your computer without copying 
or disclosing it.


Reply via email to