Skip to main content

JSON Web Services

4 replies [Last post]
farazali
Offline
Joined: 2008-11-02
Points: 0

Hi All,

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

Thank you,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
farazali
Offline
Joined: 2008-11-02
Points: 0

Thank you very very much.

I am OK now.

farazali
Offline
Joined: 2008-11-02
Points: 0

Thanks a lot.

Is the rest and json are same?

Paul Sandoz

Hi,

See the following Jersey sample:

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

and the following tech tip:

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

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

nitkal
Offline
Joined: 2008-10-22
Points: 0

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