Several ways to implement Java end RESTful Web services

Source: Internet
Author: User
Tags http request soap web services

1) using Jax-ws's Dispatch/provider to

In Jax-ws, we can skip the processing of the soap stack and call the service Endpoint directly so that we can transfer pox (RAW XML) or JSON to service Endpoint processing, And you can get HTTP method via Messagecontext to make judgments and invoke different logic. It is necessary to realize that the Provider<source> interface is replaced by replacing the endpoint @webservice with @webserviceprovider. Then change the Bindingtype to (value = httpbinding.http_binding), indicating that the direct processing is HTTP, not soap.

Dispatch and provider, respectively, correspond to the client and the server, and they are, of course, free from use.

Provider out of Dispatch

Get and delete do not need to pass HTTP body, which natively supports arbitrary client

Post and put content via HTTP header, support for any client

Via HTTP body to post and put content, you need to simulate the HTTP body format Dispatch

Dispatch out of Provider

Generate the SOAP package yourself, the server can be the soap-based Web service

2) RESTful Httpservlets

As a matter of fact, rest itself is the HTTP architecture, we can manipulate HTTP request and response directly through the HTTP servlet, and the HTTP servlet itself provides doget doPost doPut dodelete Doheader, Dooptions method, by overriding these methods, we can implement restful Web services based on the HTTP servlet

3) Jax-rs

Jax-rs (JSR 311,java API for xml-restful Web Services) is based on the annotation implementation, we annotation the way to a Java class labeled as RESTful Web Service, and labeled its methods as HTTP crud. Related annotation have @path, @Produces, @GET, @POST, @DELETE, @PUT, @PathParam, etc.

There are already a lot of out-of-the-box implementations, such as Jersey, Apache CXF, JBoss resteasy, Apache Wink. TRIAXRS, etc.

4. Some other framework

There are other third-party frameworks that allow us to publish restful Web services and write web-client, such as Restlet

5) Container Support

Some container also provide utility tools to publish Java class as a restful Web services. But the oc4j1013 is too fake,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.