WEBAPI is using the HTTP protocol, WebService is using the SOAP protocol.
Webapi is stateless and relatively webservice lighter. WEBAPI supports HTTP operations such as Get,post
HTTP SOAP Relationships
http: is a standard (TCP) for client and server-side requests and responses. The purpose of the HTTP protocol is to provide a way to publish and receive htttp pages
Client-to-server interaction with an HTTP protocol: a request is initiated by an HTTP client to establish a TCP connection to the server-specified port (by default, port 80). The HTTP server listens on that port for requests sent by the client. Once the request is received, the server (to the client) sends back a status line, such as "http/1.1 OK", and (in response) message, the message body may be the requested file, error message, or some other information.
SOAP protocol: It describes a lightweight protocol for exchanging information in a decentralized or distributed environment. SOAP, based on the HTTP protocol, is an XML-based protocol.
Different: is the underlying communication protocol, the request package format is different, the SOAP package is XML format, HTTP plain text format.
Relationship: SOAP is a communication protocol, SOAP on the basis of the HTTP protocol, the request parameters written as XML, placed on the HTTP body on the submission of a Web service server (servlet,asp, etc.) processing is completed, The result is also written as XML as response back to the client, in order to make the client and the Web service can correspond to each other, you can use WSDL as a description of this mode of communication, using the WSDL tool can automatically generate WS and client framework files, SOAP has the ability to serialize complex objects into XML.
What should I choose for WCF and Web APIs?
1. When you want to create a service that supports message, Message Queuing, duplex communication, you should choose the WCF
2, when you want to create a service, you can use a faster transmission channel, such as TCP, Named pipes or even UDP (in WCF4.5), when the other transport channels are not available can also support HTTP.
3, when you want to create an HTTP-based resource-oriented service and can use all the features of HTTP (such as URIs, Request/response header, cache, versioning, multiple content formats), you should choose the Web API
4. When you want your service to be used in browsers, phones, iphones, and tablets, you should choose the Web API
soap:simple Object Access Protocol
Simple Object Access Protocol (SOAP) is a lightweight, simple, XML-based protocol that is designed to exchange structured and solidified information on the WEB. SOAP can be used in conjunction with many existing Internet protocols and formats, including Hypertext Transfer Protocol (HTTP), Simple Mail Transfer Protocol (SMTP), Multipurpose Internet Mail Expansion Protocol (MIME). It also supports a large number of applications, from the messaging system to Remote procedure calls (RPCs).
HTTP protocol: Application layer
TCP Protocol: Transport Layer
HTTP protocol Detailed response
在接收和解释请求消息后,服务器返回一个HTTP响应消息。
The HTTP response is also made up of three parts: status line, message header, response body
1, the status line format is as follows:
Http-version Status-code reason-phrase CRLF
Where http-version represents the version of the server HTTP protocol, Status-code represents the response status code sent back by the server, and Reason-phrase represents a textual description of the status code.
The status code consists of three digits, the first number defines the category of the response, and there are five possible values:
1XX: Indication information – Indicates that the request has been received and continues processing
2XX: Success – Indicates that the request has been successfully received, understood, accepted
3XX: Redirect – A further step must be made to complete the request
4XX: Client Error – Request syntax error or request not implemented
5XX: Server-side Error – Server failed to implement legitimate request
Common status codes, status descriptions, descriptions:
$ OK//client request succeeded
Bad Request//client requests have syntax errors and cannot be understood by the server
401 Unauthorized//request unauthorized, this status code must be used with the Www-authenticate header field
403 Forbidden//server receives request, but refuses to provide service
404 Not Found//request resource not present, eg: Wrong URL entered
Internal Server error//server unexpected errors
503 Server Unavailable//server is currently unable to process client requests and may return to normal after some time
eg:http/1.1 OK (CRLF)
2. The response header is described later
3, the response body is the contents of the resources returned by the server
Http://www.cnblogs.com/li0803/archive/2008/11/03/1324746.html
The difference between WebAPI and WebService