Tip: As the popularity of RESTful WEB services continues to rise, developers need to know how to avoid pitfalls in development and get the WEB service developed to the best of their ability.
Over the past few years, we have seen a number of reasons why RESTful Web services have become popular. Here are 10 tips you should do to make your RESTful Web service a little more expensive and easier for other developers to use.
0. Don't look for an official "REST standard"
Rest is a concept, not a standard. So there's no requirement for your RESTful Web service to run in a particular way. That being said, but ...
1. Adhere to a number of criteria
> ... Your RESTful Web services should follow at least some standards! For example, user-authenticated OAuth protocols, data exchange JSON and XML, network transport, and self-control HTTP protocols also have URI standards. If you want a more complete package, the Open Data protocol OData is an effective choice (because it's big enough?). )。 Because no one says that "rest must adhere to these standards" does not mean that you should follow your own wishes.
2. Make sure your documents are flawless
using the WSDL (Web Service Definition Language) system of the SOAP protocol, if you have a WSDL-based tool that can generate code automatically, then developing a Web service is fairly straightforward. But if you use REST, because services do not need to be strictly defined, and they run on the idea that they are known to work properly. This means that the service documentation must be very rigorous. If you are going to develop a Web service make sure that your documents are hundred percent correct.
3. Provide JSON output
JSON has quickly become an important standard on the web. First, it's handy because it makes it easy for JavaScript to use WebService with a minimum amount of coding. There are now many libraries that allow the server to interact with the client's JSON very well.
4. Do not omit the XML
5. Understanding HTTP Verbs
rest Web Services is a large chunk of functionality that the HTTP protocol has already defined. The most basic part of this is the HTTP verb, such as GET, POST. While these basic functions have been well understood in rest, some ideas continue to emerge, such as using patches to update some specific attributes in the entity rather than the entire entity.
6. Understanding the importance of URI routing
restful Web Services is largely based on URIs to decide what to do. For example, in a GET request, a typical URI path contains the primary key value (or other identity key value) of an entity to retrieve the data for the entity. For example, "Http://www.example.com/service/entityname/76″ will retrieve an entity named EntityName with a primary key value of 76." Using Restweb Services,uri is not just a way to access the service, but also to control the service and as a signal carrier to communicate your needs.
7. Update maintenance under version management
A very tempting thing is that you only need to update and maintain the only version of the service. But really don't do it! Make sure you open a new branch version for maintenance every time you post an update. The simplest and most common way is to get your service URI with the version number, which is usually part of the path. One of the things people need most is to use the updated software without any new problems or warnings appearing.
8. Keep in touch with your users
Because users don't proactively discover your updates, it's important that you stay in touch with your users. For example, when you publish a new version for your service, you should send each user an email to let them know, as well as provide the old version of the defect information.
9. Provide sample code
One of the best things you need to do for your users is to provide them with sample code. Make sure that the code you give contains at least the following major development languages: Java,. NET, JavaScript, Ruby, and Python. If necessary, hire a consultant to put the code together. Because it is absolutely important for your service to be able to be adopted. Also make sure your license agreement allows your users to use your sample code without any risk, for example by using the MIT or BSD license agreement.
10 tips for making RESTful Web services more practical