WebAPI difference and the difference between WebAPI webservice and the webservice

WebAPI and the difference webservice        

Reprinted: https://blog.csdn.net/mss359681091/article/details/53353258 

webapi use the http protocol, webservice using a soap protocol 

webapi stateless webservice relatively more lightweight. webapi support such as get, post operations such as http

http soap relations

http: is a client and server side request and response standard (TCP). http protocol whose purpose is to provide a way to publish and receive methods htttp page

The interaction of a client and server protocol http: initiating a request by the HTTP client, server to establish a designated port (default port 80) TCP connection. HTTP server that is sent over the port to listen for client requests. Upon receiving the request, the server (the client) sends back a status line, such as "HTTP / 1.1 200 OK", and the (response) message, the message body of the message may be requested file, an error message, or some other information .

soap protocol: It describes how a lightweight protocol for exchanging information in a decentralized or distributed environment. soap based on http protocol, an XML-based protocol.

Different: all the underlying communication protocol, the request packet is different formats, SOAP packet format is XML, HTTP plain text.

Relationship: SOAP is a communication protocol, SOAP based on HTTP protocol, to write to XML REQUEST parameter on the HTTP BODY submit a WEB SERVICE server (SERVLET, ASP or something) after processing is complete, the results are written in XML as RESPONSE back to the UE, in order to make the UE and WEB SERVICE may correspond to each other, it can be described using WSDL file as this communication scheme, and the frame can be automatically generated file WS client using WSDL tool, SOAP comprising the complex bound to the target sequence XML's ability to go.
  

WCF and WEB API should I choose? 
  1, when you want to create a support message, the message queue service, duplex communication, you should choose WCF 
  2, when you want to create a service, you can use faster transmission channels, like TCP, Named Pipes or even UDP (in WCF4.5), while the rest of the transmission channel may be unavailable to support HTTP.
  3. When you want to create a resource for HTTP-based service and can use all the features of HTTP (such as URIs, request / response header, cached, version control , a variety of content formats), you should choose the API Web
  4, when when you want your service for browsing, mobile phones, iPhone and tablets, you should select the Web API

SOAP: Simple Object Access Protocol 
Simple Object Access Protocol (SOAP) is a lightweight, simple, XML-based protocol that is designed to be cured and exchanging structured information in a WEB. SOAP can be used and many of the existing Internet protocols and formats combination, including the Hypertext Transfer Protocol (HTTP), Simple Mail Transfer Protocol (SMTP), Multipurpose Internet Mail Extensions (MIME). It also supports call (RPC), a large number of applications from messaging systems to remote procedure.

HTTP protocol: Application Layer 
Protocol: TCP transport layer

HTTP protocol detailed response to the article

在接收和解释请求消息后,服务器返回一个HTTP响应消息。 
  • 1
  • 2

HTTP响应也是由三个部分组成,分别是:状态行、消息报头、响应正文 
1、状态行格式如下: 
HTTP-Version Status-Code Reason-Phrase CRLF 
其中,HTTP-Version表示服务器HTTP协议的版本;Status-Code表示服务器发回的响应状态代码;Reason-Phrase表示状态代码的文本描述。
状态代码有三位数字组成,第一个数字定义了响应的类别,且有五种可能取值: 
1xx:指示信息–表示请求已接收,继续处理 
2xx:成功–表示请求已被成功接收、理解、接受 
3xx:重定向–要完成请求必须进行更进一步的操作 
4xx:客户端错误–请求有语法错误或请求无法实现 
5xx:服务器端错误–服务器未能实现合法的请求 
常见状态代码、状态描述、说明: 
200 OK //客户端请求成功 
400 Bad Request //客户端请求有语法错误,不能被服务器所理解 
401 Unauthorized //请求未经授权,这个状态代码必须和WWW-Authenticate报头域一起使用 
403 Forbidden //服务器收到请求,但是拒绝提供服务 
404 Not Found //请求资源不存在,eg:输入了错误的URL 
500 Internal Server Error //服务器发生不可预期的错误 
503 Server Unavailable //服务器当前不能处理客户端的请求,一段时间后可能恢复正常 
eg:HTTP/1.1 200 OK (CRLF)

2、响应报头后述

3、响应正文就是服务器返回的资源的内容

http://www.cnblogs.com/li0803/archive/2008/11/03/1324746.html

转载:https://blog.csdn.net/mss359681091/article/details/53353258 

webapi用的是http协议,webservice用的是soap协议 

webapi无状态,相对webservice更轻量级。webapi支持如get,post等http操作

http soap关系

http:是一个客户端和服务器端请求和应答的标准(TCP)。http协议其目的是为了提供一种发布和接收htttp页面的方法

一http协议的客户端与服务器的交互:由HTTP客户端发起一个请求,建立一个到服务器指定端口(默认是80端口)的TCP连接。HTTP服务器则在那个端口监听客户端发送过来的请求。一旦收到请求,服务器(向客户端)发回一个状态行,比如”HTTP/1.1 200 OK”,和(响应的)消息,消息的消息体可能是请求的文件、错误消息、或者其它一些信息。

soap 协议:它描述了一种在分散或分布式的环境中如何交换信息的轻量级协议。soap在http协议的基础上,一个基于XML的协议。

不同:都是底层的通信协议,请求包的格式不同而已,soap包是XML格式,http纯文本格式。

关系:SOAP是个通信协议, SOAP在HTTP协议的基础上,把编写成XML的REQUEST参数, 放在HTTP BODY上提交个WEB SERVICE服务器(SERVLET,ASP什么的) 处理完成后,结果也写成XML作为RESPONSE送回用户端, 为了使用户端和WEB SERVICE可以相互对应,可以使用WSDL作为这种通信方式的描述文件,利用WSDL工具可以自动生成WS和用户端的框架文件,SOAP具备把复杂对象序列化捆绑到XML里去的能力。
  

WCF and WEB API should I choose? 
  1, when you want to create a support message, the message queue service, duplex communication, you should choose WCF 
  2, when you want to create a service, you can use faster transmission channels, like TCP, Named Pipes or even UDP (in WCF4.5), while the rest of the transmission channel may be unavailable to support HTTP.
  3. When you want to create a resource for HTTP-based service and can use all the features of HTTP (such as URIs, request / response header, cached, version control , a variety of content formats), you should choose the API Web
  4, when when you want your service for browsing, mobile phones, iPhone and tablets, you should select the Web API

SOAP: Simple Object Access Protocol 
Simple Object Access Protocol (SOAP) is a lightweight, simple, XML-based protocol that is designed to be cured and exchanging structured information in a WEB. SOAP can be used and many of the existing Internet protocols and formats combination, including the Hypertext Transfer Protocol (HTTP), Simple Mail Transfer Protocol (SMTP), Multipurpose Internet Mail Extensions (MIME). It also supports call (RPC), a large number of applications from messaging systems to remote procedure.

HTTP protocol: Application Layer 
Protocol: TCP transport layer

HTTP protocol detailed response to the article

在接收和解释请求消息后,服务器返回一个HTTP响应消息。 
  • 1
  • 2

HTTP响应也是由三个部分组成,分别是:状态行、消息报头、响应正文 
1、状态行格式如下: 
HTTP-Version Status-Code Reason-Phrase CRLF 
其中,HTTP-Version表示服务器HTTP协议的版本;Status-Code表示服务器发回的响应状态代码;Reason-Phrase表示状态代码的文本描述。
状态代码有三位数字组成,第一个数字定义了响应的类别,且有五种可能取值: 
1xx:指示信息–表示请求已接收,继续处理 
2xx:成功–表示请求已被成功接收、理解、接受 
3xx:重定向–要完成请求必须进行更进一步的操作 
4xx:客户端错误–请求有语法错误或请求无法实现 
5xx:服务器端错误–服务器未能实现合法的请求 
常见状态代码、状态描述、说明: 
200 OK //客户端请求成功 
400 Bad Request //客户端请求有语法错误,不能被服务器所理解 
401 Unauthorized //请求未经授权,这个状态代码必须和WWW-Authenticate报头域一起使用 
403 Forbidden //服务器收到请求,但是拒绝提供服务 
404 Not Found //请求资源不存在,eg:输入了错误的URL 
500 Internal Server Error //服务器发生不可预期的错误 
503 Server Unavailable //服务器当前不能处理客户端的请求,一段时间后可能恢复正常 
eg:HTTP/1.1 200 OK (CRLF)

2、响应报头后述

3, the response body is returned by the server resource content

http://www.cnblogs.com/li0803/archive/2008/11/03/1324746.html

Guess you like

Origin www.cnblogs.com/wangcl-8645/p/11391399.html