The Source for Java Technology Collaboration

Home » java.net Forums » GlassFish » GlassFish

Thread: JSON Web Services

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 4 - Last Post: Nov 7, 2008 7:54 PM by: farazali
farazali

Posts: 10
JSON Web Services
Posted: Nov 6, 2008 8:24 AM
 
  Click to reply to this thread Reply

Hi All,

I am curious about JSON web services. How to create, deploy and consume a JSON web service in glassfish?

Thank you,

nitkal

Posts: 46
Re: JSON Web Services
Posted: Nov 6, 2008 9:17 AM   in response to: farazali
 
  Click to reply to this thread Reply

For developing JSON webservices (RESTful webservices), Jersey could be used on glassfish. Please check this link (https://jersey.dev.java.net/use/getting-started.html) for developing and deploying sample applications using Jersey on glassfish.The output format could be specified as JSON or XML.

To consumer the webservice,
i) from the command line, curl could be used
ii) from a web application, an XmlHttpRequest is to be created and sent.
The response in JSON format could be handled by the callback methods. Javascript libraries like jQuery or the jMaki toolkit (that is available as a Netbeans plugin as well) could be used to simplify the handling of XHR and the response.

HTH,
Nithya

farazali

Posts: 10
Re: JSON Web Services
Posted: Nov 6, 2008 6:21 PM   in response to: farazali
 
  Click to reply to this thread Reply

Thanks a lot.

Is the rest and json are same?

Paul Sandoz
Re: JSON Web Services
Posted: Nov 7, 2008 12:14 AM   in response to: farazali
  Click to reply to this thread Reply

Hi,

See the following Jersey sample:

http://download.java.net/maven/2/com/sun/jersey/samples/json-from-jaxb/1.0/json-from-jaxb-1.0-project.zip

and the following tech tip:

http://blogs.sun.com/enterprisetechtips/entry/configuring_json_for_restful_web


JSON and REST are not the same.

JSON is a data format that is a subset of the JavaScript language and
as a result the format is very easy to produce and consume by
JavaScript programs e.g. those running in Web browsers. But it can
also be for JavaScript servers like Phobos.

REST is an architectural style that declares constraints. If those
constraints are applied to your architecture then it induces certain
desirable properties, like loose coupling or scalability, which are
important when building applications for the Web.

The relationship between JSON and RESTful Web applications is as
follows: Resources, identified by URLs, produce and consume
representations when a client makes a request using an HTTP method.
The representations are identified by a media type, which describes
what the representation is. Such a representation may be a JSON
document and might be identified by the media type "application/json".
JSON is just one of many data formats you may choose to use in your
Web application.

Hope that helps,
Paul.

On Nov 7, 2008, at 3:21 AM, glassfish@javadesktop.org wrote:

> Thanks a lot.
>
> Is the rest and json are same?
> [Message sent by forum member 'farazali' (farazali)]
>
> http://forums.java.net/jive/thread.jspa?messageID=315377
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net


farazali

Posts: 10
Re: JSON Web Services
Posted: Nov 7, 2008 7:54 PM   in response to: farazali
 
  Click to reply to this thread Reply

Thank you very very much.

I am OK now.




 XML java.net RSS