First why we use this technologies?
If you have any logic and need to make it shared and compatible with any machines and any software you will need to put this logic or methods on the web or shared network and make results as XML or JSON to be compatible with different framework .
so you will need technologies such as web service , web api , WCF to make this
Web Services
used to make your logic code accessible over web and HTTP protocol.
web services use SOAP (Simple Object Access Protocol) that use HTTP + XML
web services return its result as XML (Extensible Markup Language) and can return JSON (JavaScript Object Notation) but common that return XML
web services is action-based model that mean web services contain action not related to specific object or resource for example web service contain method for Add two integer numbers and method for Add two complex numbers and method for multiply and so on all in one web services
commonly using web service in simplex communication (Server to Client ) not in half duplex or full duplex communication
to create Web service for example in . net create web service project and add your methods and decorated it [web method] attribute and to use it add web reference
web service use WSDL (web services Description Language) to describe web service and its functionality
and use UDDI (universal Description ,Discovery and Integration ) to hosting and publishing web services
Web API
- Uniform Interface
- Stateless
- Cacheable
- Client -Server
- Layered System
- Code on demand (optional)
Uniform Interface:
Stateless
Cacheable
Client -Server
Layered System
Code on demand
WCF
it is Microsoft technology to build logic on web like web service and web API
but WCF is more larger and detailed . WCF not depend on only HTTP Protocol but it can use other different network protocol like TCP , MSMQ and more
WCF used to build any communication types Simple , half duplex , full duplex
to create WCF :
create data contract to define result data and its members to serialization / deserialization
and make them by decorate interface [DataContract] attribute and its memeber [DataMember]
create service contract to define services functionality structure
and decorate interface [ServiceContract] and its methods [OperationContract]
implement service contract interface and define method logic in service class
define end point (ABC)
A => Address of service
B => Binding Protocol
C =>Contract