webservice concept excerpt

WebService is a very heavy specification, its application protocol is SOAP (Simple Object Access Protocol),

The underlying communication method it relies on is not only HTTP, but also SOAP over SMTP, SOAP over TCP,

Because the HTTP protocol has a wide base of people and is convenient for development and debugging, it has become the most popular way in WebService.

 

SOAP is Simple Object Access Protocol, which defines a cross-platform communication protocol for distributed systems.

SOAP needs to be bound to lower-level transport protocols (eg, HTTP, RMI, JMS), etc.

The most commonly used is the HTTP binding, so the concept of SOAP is often confused with HTTP.

 

Or it can be simply understood as:

To put it bluntly, SOAP is just using http to transmit xml.

SOAP protocol = HTTP protocol + XML data format

 

Due to the xml parsing of webservice, the speed will be reduced.

 

Today's open platforms all use HTTP interfaces and no longer use webservices.

 

When there was a problem of interaction between different systems, webserivce was always given priority,

Now I see that in addition to some old-fashioned companies, such as amazonk, the interface to the public is still the way of webservice,

The interfaces of many other new domestic projects have begun to transfer json directly.

 

WebService has been born for more than ten years. It was initially promoted by IBM and Microsoft, and it has been tepid.

The reason is that WebService is too cumbersome,

The SOAP envelope is like a mother-in-law's foot-binding cloth, which is smelly and long. Most developers can't bear it.

So there is a simplified version, called XML-RPC, and later, RESTful dominates.

 

In some areas where the business is complex and requires high stability and correctness (such as ERP, e-commerce, payment),

There is still a place for WebServices.

 

JSON is more readable than XML, and the parsing rules are much simpler.

There are too many rules in XML parsing, illegal characters are always thrown, and exceptions are thrown at every moment.

This is a fatal blow for companies that pursue high development speed and low development threshold.

 

The disadvantage of JSON is that there is less data type support and it is imprecise.

For example: in json, you can't know if the price is int, float or double.

 

JSON is indeed a great interchange data structure.

除了这个之外,javascript原生支持json解析,且解析起来很简单。这个很重要,

因为http接口大部分是给页面的Javascript解析使用的。

然后为了保持一套接口,app代码也使用这个json接口。所以就流行了起来。

 

webservice通过xml来传数据的方式导致大量的验证、类型分析、异常处理,性能损耗很大,

并且开发也过于复杂。xml相关的库也很大。

 

面向一般开发者的API,显然应该考虑简单易用。

而且公开到Web环境中,性能也很重要。

JSON这种适应性超强的格式受欢迎也就很正常了。

 

XML 是强类型的,在整个解析过程中很多时间都被花在类型检测上了;

JSON 则是弱类型,完全依赖两端代码共同遵守同一界面合约(contract)来保障。

 

 SOAP请求示例

<?xml version="1.0" ?>
<S:Envelope
    xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:get
            xmlns:ns2="http://service.com/">
            <arg0>张三</arg0>
        </ns2:get>
    </S:Body>
</S:Envelope>

 

 

 SOAP响应示例

 

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:getResponse xmlns:ns2="http://service.com/">
            <return>你好,张三</return>
        </ns2:getResponse>
    </S:Body>
</S:Envelope>

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326279072&siteId=291194637