Developing an JSON-RPC protocol-based interface using Jayrock open source components

Source: Internet
Author: User

Recently took over a previous project, inadvertently found the component of this project development interface: Jayrock (the interface component is less estimated, the most estimated is this Jayrock.json.dll, used to parse the JSON)

The following is an introduction to Jayrock's website:

https://atifaziz.github.io/projects/jayrock/

If you use this component in development, the official website above will be a good introductory tutorial.

In the process of research, we find that Jayrock has the following specific, mainly from the development of the direction of the analysis.

The advantages are as follows:

1, interface development and deployment of simple, directly inherit the components of the Jsonrpchandler, and then carry out their own business development, however, you can use the entity's Ashx file or in Web. config to take over the global HttpHandler way to use;

2, has the interface help page and the test page, this method is actually very suitable for the mobile side or the third party needs to call the personnel to use, can quickly understand the interface's use and the test data return JSON format;

3, the domain calls the background of the interface, the direct use of the proxy mode, the HTML page automatically generated an interface JS call class directly using the form of a method call interface, discard the traditional way of write requests (really save the workload of front-end developers);

4, cross-domain, as long as in the background Code development interface, logo cross-domain identification, directly using the GETRPC mode, you can easily make cross-domain calls (the cross-domain JS can only be obtained), but each interface code has to write itself;

5, the interface JSON format uses the JSONRPC format, for the JSON definition, provides the unification;

Shortcomings, is also in the ointment of it:

1, because the entire component in the JSONRPC format, then the component in the package, in the case of uploading photos or files, completely did not consider using the form of flow, can only say the file into the Base64 format, and then loaded into the JSON field, and submit; Then the question comes, Base64 tell the picture conversion, the data will become much larger, the flow loss is large;

2, although the method can write comments, but the comments for each parameter is not, it may be the author's idea is that the parameter name is intuitive;

3, the parameters of the interface, each is necessary, can not be passed, but when we develop the interface, some specific requirements, will make some parameters passed to null, such as the search interface is a typical example;

4, the overall adoption of the JSONRPC agreement, the flow is naturally large so little, but, for the general business system, these can be neglected;

Here are some of the picture processes I've developed:

1, the development of the interface

1) Physical file mode:

  

2) Web. config takeover mode

  

2. Interface's help page and test page

1) help page, clear

  

2) Interface test page, automatically show which parameters, to mobile development is indeed a good choice

  

3. This domain call:

  

is not very simple, very cool;

4, cross-domain call form, this is my hard million bitter in a foreigner's website on a problem found on

It is very simple to use, as long as you mark Idempotent = True on the interface, and then call it as follows:

  

5, JSON-RPC protocol description, Direct introduction of the website: http://www.json-rpc.org/

Summarize:

The above is my research on the jayrock components, in fact, the advantages of the above-mentioned MVC Web API can be fully implemented, Help and test page only need to download the extension of nuget;

The following is the entire file of the component, including some examples, because Google Code management is about to close (only to read-only mode), so I sorted out the most complete:

Click to download

Developing an JSON-RPC protocol-based interface using Jayrock open source components

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.