WebServices

Thursday, September 26, 2013

Receives input, processes it and returns output

Mashup combine multiple web service calls in an application

Communication over the entire internet

Characteristics:

  1. Accesses using web standards methods, mostly HTTP
  2. Clients just need to know how to send and receive HTTP
  3. RPC, SOAP, WSDL
  4. Web API relies on HTTP to send and receive data in json or xml format
  5. REST use HTTP Verbs to perform actions
  6. POST, GET, PUT, DELETE, stateless resources and clean URLs

ASMX Web Service

  • the first way to build web services in .NET
  • supports SOAP v1.1 and v1.2, HTTP Post
  • web service and web method attributes
  • automatically generates WSDL


WCF

  • Message Based Communication on Client And Server
  • Multiple Transports and Encodings
  • Used by WF, Biz Talk Server, Silverlight RIA and App Fabric
  • Service Contract define capabilities of service
  • Operation Contract defines arguments and return values of specific operations
  • Data Contract defines the type and format of data received

Data Contract


Service Contract


Implementation


Server Side Configuration


Client Side Configuration



ASP.NET MVC 4, Model-View-Controller

  • Model: Data and its operations
  • Controller: handles interaction between client and server
  • View: representation of data: html, json, xml...
  • Routing: maps request to controller action method
  • Web Api: requests are mapped to HTTP Verbs: get, post, put, delete...
  • Convention over configuration: rely on proven standards
  • Controllers reside in controllers folder and extend controllers class or webapi class

Default WebApi Route Configuration


API Get Method


Result invoking in the browser


Compose Request in Fiddler, specify json header


Default Success Warning Important Info Inverse
B S W I ? O