[Link] can you pass multiple complex types in Web API?
A. Two methods to pass the complex types in Web API –Using ArrayList and Newtonsoft array
2. Write a code for passing ArrayList in Web API?
ArrayList paramList = new ArrayList();
Category c = new Category { CategoryId = 1, CategoryName =“MobilePhones”};
Product p = new Product { Productcode = 1, Name = “MotoG”, Price = 15500, CategoryID = 1 };
[Link](c);[Link](p);
3. ) What is REST?
REST is architectural style. It has defined guidelines for creating services which are scalable. REST used
with HTTP protocol using its verbs GET, PUT, POST and DELETE. Rest stands for Representation State
Transfer. Because it is light weight and fast it is used in mobile application
4. restrict web API by using verbs and attribute programming.
[Link] register html filter we use notimplexception filter
6.404 is not found error created by [Link] errorresponse( [Link],message)
[Link] Pai supports http protocol and supports net 4 .0 version
8.500: internal several error and uncaught exception
9. What is the benefit of WebAPI over WCF?
WCF services use the SOAP protocol while HTTP never use SOAP protocol. That’s why WebAPI services
are lightweight since SOAP is not used. It also reduces the data which is transferred to resume service.
Moreover, it never needs too much configuration. Therefore, the client can interact with the service by
using the HTTP [Link] never have views
10. What are the RESTful Services?
REST stands for the Representational State Transfer. This term is coined by the Roy Fielding in 2000.
RESTful is an Architectural style for creating loosely couple applications over the HTTP. In order to make
API to be RESTful, it has to adhere the around 6 constraints that are mentioned below:
1. Client and Server Separation: Server and Clients are clearly isolated in the RESTful services.
2. Stateless: REST Architecture is based on the HTTP Protocol and the server response can be
cached by the clients, but no client context would be stored on the server.
3. Uniform Interface: Allows a limited set of operation defined using the HTTP Verbs. For eg: GET,
PUT, POST, Delete etc.
4. Cacheable: RESTful architecture allows the response to be cached or not. Caching improves
performance and scalability.
5. Code-On-Demand ,Layered System
11. What are HTTP Status Codes?
HTTP Status Code Is 3-digit integer in which the first digit of the Status-Code defines
the class of response. Response Header of each API response contains the HTTP Status
Code. HTTP Status Codes are grouped into five categories based upon the first number.
S. No. HTTP Status Code Description
1. 1XX Informational
2. 2XX Success
3. 3XX Redirection
4. 4XX Client-Side Error
5. 5XX Server-Side Error
Table: HTTP Status Code with Description
Some of the commonly seen HTTP Status Codes are: 200 (Request is Ok), 201 (Created), 202
(Accepted), 204 (No Content), 301 (Moved Permanently), 400 (Bad Request), 401 (Unauthorized),
403 (Forbidden), 404 (Not Found), 500 (Internal Server Error), 502 (Bad Gateway), 503 (Service
Unavailable) [Link] v cde3
12. What is Content Negotiation in Web API?
Content Negotiation is the process of selecting the best representation for a given response when
there are multiple representations available. Two main headers which are responsible for the
Content Negotiation are:
Content-Type
Accept
The content-type header tells the server about the data, the server is going to receive from the
client whereas another way to use Accept-Header, which tells the format of data requested by the
Client from a server. In the below example, we requested the data from the server in JSON format.
13. void - Return empty 204 (No Content)
HttpResponseMessage - Return empty 204 (No Content)
IHttpActionResult - Call ExecuteAsync to create an HttpResponseMessage, then convert to an HTTP
response message,Some other type - Write the serialized return value into the response body;
return 200 (OK).
PCDATA means parseable character data.
DTD means document type definition . it defines structure and legal elemnts
of xml
XML Schemas are More Powerful than DTD
XML Schemas are written in XML
XML Schemas are extensible to additions
XML Schemas support data types
XML Schemas support namespaces
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
AJAX = Asynchronous JavaScript And XML.
onreadystatechange Defines a function to be called when the readyState
readyState Holds the status of the XMLHttpRequest.
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
responseText Returns the response data as a string
responseXML Returns the response data as XML data
status Returns the status-number of a request
200: "OK"
403: "Forbidden"
404: "Not Found"
For a complete list go to the Http Messages Referen
statusText Returns the status-text (e.g. "OK" or "Not Found")
Get can give us cache result for gewtting unique we can add id
Node type NodeType
Element 1
Attribute 2
Text 3
Comment 8
Document 9