API SOA and data formats

Source: Internet
Author: User
Tags addchild soap


Defined:

The API represents an application programming interface, and an interface refers to a specific service, an application, or a public module that interacts with other applications.

Reasons to use the API:

Make data available to other systems or modules

Provide data to a Web site in an asynchronous manner

Form the basis for a server-oriented architecture

So these reasons have a huge effect on enhancing API functionality, in fact, most modern systems require some form of API because we are increasingly collecting data from disparate systems. For developers with common web development experience, the first two are relatively easy to do.

1. Service-Oriented Architecture

SOA (service-orientedarchitecture, service-oriented architecture) is an increasingly popular approach in various PHP applications. He is a service-tier based system that provides all the functionality the system needs, but this service provides an application layer that is not linked to the presentation layer. This allows multiple systems to use the same modular, reusable functionality. In other words, you can write a service layer, and then several other applications can use the service layer.

The SOA approach allows us to use, test, and harden the code of the Application service layer, and easily apply it to the service layer in its MVC approach,

2. Data format

1) using JSON

JSON (JavaScript objectnotation) is a way of representing JS objects, but many modern languages use the built-in features of this format. This is a format based on text, used for table water arrays or object amounts, and is similar to PHP serialization.

JSON is a lightweight format: The packet is small and simple, which makes it easy for us to handle it. Since we use JSON design for JS, it is the best choice for JS to use the API.

In PHP, the Json_encode () function writes JSON with Json_decode () to read it back.

"Example":

<span style= "Font-family:microsoft yahei;font-size:18px;" >< $concerts = Array (        "title" and "Veaglefly", "Time" = "Today"),        Array ("title" and "=" Xiaoming "," Time "=" Yeastoday "), $temp = Json_encode ($concerts); Echo Json_encode ($concerts); echo" <pre> "; Print_r (Json_decode ($temp));   echo "</pre>";</span>


Output:




2) Using XML

XML represents extensible Markup language. It is a standard way to represent machine-readable data on many platforms.

XML is a more verbose format than JSON. It contains more data types of information, and different operating systems will use different tags and attributes for detailed descriptive information.

"Example 1":

<span style= "Font-family:microsoft yahei;font-size:18px;"        ><?xmlversion= "1.0" encoding= "UTF-8"?><configdata>

"Example 2":

<span style= "Font-family:microsoft yahei;font-size:18px;" ><?       $sxml = newsimplexmlelement (       ' <?xml Version = "1.0"? ><concerts/> '       );       $concert 1 = $sxml->addchild (' Concert ');       $concert 1, AddChild ("title", "Veaglefly");       $concert 1->addchild ("Time", "Today");             $concert 2 = $sxml->addchild (' Concert ');       $concert 2->addchild ("title", "Veaglefly");       $concert 2->addchild ("Time", "Yeastoday");       $txml = $sxml->asxml ();       Echo $sxml-Asxml ();       $concert _list =simplexml_load_string ($txml);       echo "<pre>";       Print_r ($concert _list);       echo "</pre>";   </span>

  

1. Abbreviations for RPC Remote call procedures. The RPC service is where the function is called and the parameters are passed in.

2. SOAP Simple Object Access Protocol. The SOAP service is typically described using the WDSL (Web Service Description Language) document, which is a set of definitions that describe a Web service.

3. Rest is different from the first two terms, rest is not a protocol, he does not have a strict interface and data format, but more like a set of design principles, rest treats each project as a resource, we execute the action by sending the correct verb to the URL for the resource.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

API SOA and data formats

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.