Uploaded on Jun 3, 2019
Web Services are means for interacting with objects over the Internet. Web Service messages are formatted as XML, a standard way for communication between two incompatible system. And this message is sent via HTTP, so that they can reach to any machine on the internet without being blocked by firewall.
Introduction of Web Services
iFoWure Cbo Snesruvilcteasncy
https://www.ifourtechnolab.com/
INDEX
Introduction to Web Service
SOAP (Simple Object Access Protocol)
WSDL (Web Service Description Language)
WSDL Components
WCF (Windows Communication Foundation)
Advantages of WCF
Difference between WCF and Web service
WCF Service Components
Address
Binding
Contract
REST
WEB API
https://www.ifourtechnolab.com/
Introduction to Web Service
An application that is designed to interact directly with other applications over the
internet
In simple sense, Web Services are means for interacting with objects over the Internet
The Web service consumers are able to invoke method calls on remote objects by using
SOAP and HTTP over the Web
It is language independent and Web Services communicate by using standard web
protocols and data formats, such as
HTTP
XML
SOAP
https://www.ifourtechnolab.com/
Introduction to Web Service (Cont.)
Flow
https://www.ifourtechnolab.com/
Introduction to Web Service (Cont.)
Advantage:
Web Service messages are formatted as XML, a standard way for communication
between two incompatible system. And this message is sent via HTTP, so that they can
reach to any machine on the internet without being blocked by firewall
https://www.ifourtechnolab.com/
Types of Web service
SOAP - Simple Object Access Protocol
REST - Representation State Transfer
Three ways we can develop web service
ASMX Web Service (SOAP)
WCF (SOAP /REST)
ASP.NET Web API ( REST)
https://www.ifourtechnolab.com/
Web service request and response flow
SOAP-REST Web service Communication Flow
https://www.ifourtechnolab.com/
Web service request and response flow Cont.
Web service Communication Flow
https://www.ifourtechnolab.com/
SOAP (Simple Object Access Protocol)
Remote function calls that invokes method and executes them on Remote machine and
translate the object communication into XML format
In short, SOAP are way by which method calls are translate into XML format and sent via
HTTP
https://www.ifourtechnolab.com/
SOAP (Cont.)
SOAP and XML created the solution for the problem that developers were facing before
Standard XML based protocol that communicated over HTTP
SOAP is message format for sending messaged between applications using XML. It is
independent of technology, platform and is extensible too
SOAP and XML to give us connectivity between applications
https://www.ifourtechnolab.com/
WSDL (Web Service Description Language)
A Standard by which a web service can tell clients what messages it accepts and which
results it will return
Contains every detail regarding using web service and Method and Properties provided by
web service and URLs from which those methods can be accessed and Data Types used
The operations and messages are described abstractly, and then bound to a concrete
network protocol and message format to define an endpoint
Related concrete endpoints are combined into abstract endpoints (services)
It is extensible to allow description of endpoints and their messages regardless of what
message formats or network protocols are used to communicate, however, the only
bindings described in this document describe how to use WSDL in conjunction with SOAP
https://www.ifourtechnolab.com/
WSDL Components
https://www.ifourtechnolab.com/
WSDL Components (Cont.)
WSDL 1.1 Term WSDL 2.0 Term Description
Contains a set of system functions
Service Service that have been exposed to the
Web-based protocols
Defines the address or connection
Port Endpoint point to a Web service. It is
typically represented by a simple
HTTP URL string
Specifies the interface and defines
the SOAP binding style (RPC
Binding Binding /Document) and transport (SOAP
Protocol). The binding section also
defines the operations
https://www.ifourtechnolab.com/
WSDL Components (Cont.)
PortType Interfa Defines a Web service, the operations that can be performed, and the messages that are
ce used to perform the operation
Operation Opera Defines the SOAP actions and the way the message is encoded, for example, "literal." An
tion operation is like a method or function call in a traditional programming language
Typically, a message corresponds to an operation. The message contains the information
needed to perform the operation. Each message is made up of one or more logical parts.
Each part is associated with a message-typing attribute
Message n/a The message name attribute provides a unique name among all messages. The part name attribute provides a unique name among all the parts of the enclosing message.
Parts are a description of the logical content of a message. In RPC binding, a binding may
reference the name of a part in order to specify binding-specific information about the
part
Types Types Describes the data. The XML Schema language (also known as XSD) is used (inline or
referenced) for this purpose
https://www.ifourtechnolab.com/
WCF (Windows Communication Foundation)
Programming platform and runtime system for building, configuring and deploying
network-distributed services
Latest service oriented technology, Interoperability is the fundamental characteristics of
WCF
Unified programming model provided in .NET Framework 3.0
Combined feature of Web Service, Remoting, MSMQ and COM+
Provides a common platform for all .NET communication
https://www.ifourtechnolab.com/
Advantages of WCF
Interoperable with other services when compared to .NET Remoting where the client and
service have to be .NET
Provide better reliability and security in compared to ASMX web services.
No need to make much change in code for implementing the security model and changing
the binding. Small changes in the configuration will make our requirements
Integrated logging mechanism, changing the configuration file settings will provide this
functionality
https://www.ifourtechnolab.com/
Difference between WCF and Web service
Features Web Service WCF
It can be hosted in IIS, windows activation service, Self-hosting, Windows
Hosting It can be hosted in IIS service
Programming [WebService] attribute has to be added to [ServiceContract] attribute has to be added to the class
the class
Model [WebMethod] attribute represents the [OperationContract] attribute represents the method exposed to client
method exposed to client
One-way, Request- Response are the One-Way, Request-Response, Duplex are different type of operations
Operation different operations supported in web
service supported in WCF
XML System.Xml.serialization name space is System.Runtime.Serialization namespace is used for serialization
used for serialization
XML 1.0, MTOM(Message Transmission
Encoding XML 1.0, MTOM, Binary, Custom
Optimization Mechanism), DIME, Custom
Transports Can be accessed through HTTP, TCP, Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom
Custom
Protocols Security Security, Reliable messaging, Transactions
https://www.ifourtechnolab.com/
WCF Service Components
A WCF Service is composed of three components :
Service Class - It implements some service as a set of methods
Host Environment - It can be a Console application or a Windows Service or a Windows Forms
application or IIS as in case of the normal .asmx web service in .NET
Endpoints - All communications with the WCF service will happen via the endpoints. The endpoint
is composed of 3 parts (collectively called as ABC's of endpoint) as defines below:
Address
Binding
Contract
https://www.ifourtechnolab.com/
Address
The endpoints specify an Address that defines where the endpoint is hosted
It’s basically url
Example:
http://localhost/WCFServiceSample/Service.svc
https://www.ifourtechnolab.com/
Binding
The endpoints also define a binding that specifies how a client will communicate with the
service and the address where the endpoint is hosted
Different Bindings supported by WCF:
Binding Description
Basic Web service communication. No security by
BasicHttpBinding
default
Web services with WS-* support. Supports
WSHttpBinding transactions
WSDualHttpBinding Web services with duplex contract and transaction support
https://www.ifourtechnolab.com/
Binding (Cont.)
WSFederationHttpBinding Web services with federated security. Supports transactions
MsmqIntegrationBinding Communication directly with MSMQ applications. Supports transactions
NetMsmqBinding Communication between WCF applications by using queuing. Supports transactions
NetNamedPipeBinding Communication between WCF applications on same computer. Supports duplex contracts and transactions
Communication between computers across peer-to-peer services.
NetPeerTcpBinding Supports duplex contracts
NetTcpBinding Communication between WCF applications across computers. Supports duplex contracts and transactions
BasicHttpBinding Basic Web service communication. No security by default
WSHttpBinding Web services with WS-* support. Supports transactions
https://www.ifourtechnolab.com/
Contract
The endpoints specify a Contract that defines which methods of the Service class will be
accessible via the endpoint; each endpoint may expose a different set of methods
Different contracts in WCF:
Service Contract
It describe the operation that service can provide. For E.g., A Service provide to know the temperature of
the city based on the zip code, this service is called as Service contract
It will be created using Service and Operational Contract attribute
Message Contract
Default SOAP message format is provided by the WCF runtime for communication between Client and
service
If it is not meeting requirements then we can create our own message format. This can be achieved by
using Message Contract attribute
https://www.ifourtechnolab.com/
Contract (Cont.)
Data Contract
It describes the custom data type which is exposed to the client. This defines the data types,
which are passed to and from service
Data types like int, string are identified by the client because it is already mention in XML
schema definition language document, but custom created class or data types cannot be
identified by the client e.g. Employee data type
By using Data Contract we can make client to be aware of Employee data type that are returning
or passing parameter to the method
Fault Contract
Suppose the service we consumed is not working in the client application. we want to know the
real cause of the problem. How we can know the error? For this we are having Fault Contract
Fault Contract provides documented view for error occurred in the service to client. This helps
us to easy identity, what error has occurred
https://www.ifourtechnolab.com/
REST
REST stands for ‘Representational State Transfer’ and it is an architectural pattern for
creating an API that uses HTTP as its underlying communication method
Almost every device that is connected to the internet already uses HTTP, it is the base protocol that
the internet is built on which is why it makes such a great platform for an API
HTTP is a request and response system, a calling client sends a request to an endpoint and the
endpoint responds
The client and endpoint can be anything but a typical example is a browser accessing a web server
or an app accessing and API
https://www.ifourtechnolab.com/
REST (Cont.)
There are several key implementation details with HTTP that you should be aware of:
Resources - REST uses addressable resources to define the structure of the API. These are the URLs you use to get
to pages on the web
Example: ‘http://www.microsoft.com/Surface-Pro-3’ is a resource
Request Verbs - A browser typically issues a GET verb to instruct the endpoint it wants to get data, however there
are many other verbs available including things like POST, PUT and DELETE
Request Headers - Additional instructions that are sent with the request. These might define what type of response
is required or authorization details
Request Body - Data that is sent with the request
Example: A POST (creation of a new item) will required some data which is typically sent as the request body in the format
of JSON or XML
Response Body - Main body of the response. If the request was to a web server, this might be a full HTML page, if it
was to an API, this might be a JSON or XML document
Response Status codes - These codes are issues with the response and give the client details on the status of the
request
https://www.ifourtechnolab.com/
WEB API
The term API stands for ‘Application Programming Interface’
In the world of web development the term ‘API’ is synonymous with online web services
which client apps can use to retrieve and update data
These online services have had several names/formats over the years such as SOAP,
however the current popular choice is to create a REST (or RESTful) API
https://www.ifourtechnolab.com/
References
http://www.tutorialspoint.com/webservices/
http://www.w3schools.com/xml/xml_services.asp
http://www.c-sharpcorner.com/uploadfile/00a8b7/web-service/
https://www.tutorialspoint.com/asp.net/asp.net_web_services.htm
https://www.ifourtechnolab.com/
Thank You..
https://www.ifourtechnolab.com/
Comments