This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Services and the fly likes Restful java client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Restful java client" Watch "Restful java client" New topic
Author

Restful java client

Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
hi,
i want to know how can i genere xsd files from class files in order to have right response in my client rest.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
Why do you think that is necessary?

What class files are you talking about?

RESTful services can return any resource - not like SOAP services so XSD does not apply.

Various attempts to come up with abstract descriptions of RESTful services seem to be going nowhere. The big services like Amazon depend on text descriptions plus example code.

Bill
Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
In my client rest, i should have a list of person, how can i get some properties of each person (eg name)..
thanks a lot
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
Doesn't that depend entirely on what format the service sends the data in?

What information do you have about the service?

Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
that's my problem! In the classe ressource of Person, get method return a PersonConverter jaxb... how the client rest should know about the PersonConverter
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
Who is in charge of this web service you are trying to access?

What kind of documentation do you have on the implementation of the service?

Bill
Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
i'm implementing both rest WS and client. i'm wondering about tech to use in order to assure the communication between the two projects.
thans for your help, i really nedd it.
Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
should i use @provider annotation in my service class?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
If you have already chosen RESTstyle web service, then one of the few things remaining to decide on is the format of the representation generated by the service.
XML and/or JSON.
In order to be able to decide, I would examine whether the client platform and server platform (for instance Java or .NET) have some suitable library for efficient marshalling and unmarshalling of the representation format you prefer.
If the server is to be implemented in Java, then a question is whether you want to deploy it as a standalone application or in a web container like Tomcat?
I would implement a standalone Java server using the Restlet framework. For a service that is to be deployed in a container, I would choose some framework that implements JAX-RS.
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
I'm actually using netbeans with glassfish and jersey. Please, what do you mean by "some suitable library for efficient marshalling and unmarshalling of the representation format you prefer"
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
What Ivan said!

Another alternative to XML or JSON is a simple text file in the "properties" style - one line per value - "name=value"

The initial question here started way way too close to the problem with some assumptions about the technology which turned out to be a false trail. The best way to get good answers here is to back off a bit and state the problem in more general terms.

Bill
Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
Hi Bill,
can you give me your suggestion more clearly. i'm novice in this domain.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
Essentially my suggestion is to state your problem in terms which have a minimum of assumptions about particular technology such as JAXB.

You apparently have data managed by a server which you would like to expose as a RESTful service.

You want to do a GET type HTTP request which tells the server which record to return. ? by the person name ?

The server should return certain information to the client in a format which will be easy to interpret for the client to use.

Seems to me the format depends on how complex the data is, so give an example.


Bill
(Have you run through any to the Jersey samples? As I recall there is a nice variety)
Smari Oumaya
Greenhorn

Joined: Sep 29, 2010
Posts: 22
thank you for alls!
your answers were very helpful! all the treatments must be in the service description. My problem is resolved.
Oumaya
 
jQuery in Action, 2nd edition
 
subject: Restful java client