Top Banner
iFour Consultancy Web Services
28

Web Services by iFour Technolab Pvt. Ltd.

Apr 11, 2017

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web Services by iFour Technolab Pvt. Ltd.

iFour Consultancy

Web Services

Page 2: Web Services by iFour Technolab Pvt. Ltd.

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

INDEX

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 3: Web Services by iFour Technolab Pvt. Ltd.

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 asHTTPXMLSOAP

Introduction to Web Service

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 4: Web Services by iFour Technolab Pvt. Ltd.

Flow

Introduction to Web Service (Cont.)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 5: Web Services by iFour Technolab Pvt. Ltd.

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

Introduction to Web Service (Cont.)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 6: Web Services by iFour Technolab Pvt. Ltd.

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)

Types of Web service

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 7: Web Services by iFour Technolab Pvt. Ltd.

SOAP-REST Web service Communication Flow

Web service request and response flow

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 8: Web Services by iFour Technolab Pvt. Ltd.

Web service Communication Flow

Web service request and response flow Cont.

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 9: Web Services by iFour Technolab Pvt. Ltd.

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

SOAP (Simple Object Access Protocol)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 10: Web Services by iFour Technolab Pvt. Ltd.

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

SOAP (Cont.)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 11: Web Services by iFour Technolab Pvt. Ltd.

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

WSDL (Web Service Description Language)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 12: Web Services by iFour Technolab Pvt. Ltd.

WSDL Components

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 13: Web Services by iFour Technolab Pvt. Ltd.

WSDL 1.1 Term WSDL 2.0 Term Description

Service ServiceContains a set of system functions that have been exposed to the Web-based protocols

Port EndpointDefines the address or connection point to a Web service. It is typically represented by a simple HTTP URL string

Binding Binding

Specifies the interface and defines the SOAP binding style (RPC/Document) and transport (SOAP Protocol). The binding section also defines the operations

WSDL Components (Cont.)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 14: Web Services by iFour Technolab Pvt. Ltd.

PortType Interface

Defines a Web service, the operations that can be performed, and the messages that are used to perform the operation

Operation Operation

Defines the SOAP actions and the way the message is encoded, for example, "literal." An operation is like a method or function call in a traditional programming language

Message n/a

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 attributeThe 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

WSDL Components (Cont.)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 15: Web Services by iFour Technolab Pvt. Ltd.

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

WCF (Windows Communication Foundation)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 16: Web Services by iFour Technolab Pvt. Ltd.

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

Advantages of WCF

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 17: Web Services by iFour Technolab Pvt. Ltd.

Features Web Service WCF

Hosting It can be hosted in IIS It can be hosted in IIS, windows activation service, Self-hosting, Windows service

Programming [WebService] attribute has to be added to the class [ServiceContract] attribute has to be added to the class

Model [WebMethod] attribute represents the method exposed to client [OperationContract] attribute represents the method exposed to client

OperationOne-way, Request- Response are the different operations supported in web service

One-Way, Request-Response, Duplex are different type of operations supported in WCF

XML System.Xml.serialization name space is used for serialization System.Runtime.Serialization namespace is used for serialization

Encoding XML 1.0, MTOM(Message Transmission Optimization Mechanism), DIME, Custom XML 1.0, MTOM, Binary, Custom

Transports Can be accessed through HTTP, TCP, Custom Can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P, Custom

Protocols Security Security, Reliable messaging, Transactions

Difference between WCF and Web service

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 18: Web Services by iFour Technolab Pvt. Ltd.

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

WCF Service Components

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 19: Web Services by iFour Technolab Pvt. Ltd.

The endpoints specify an Address that defines where the endpoint is hosted It’s basically url Example:

http://localhost/WCFServiceSample/Service.svc

Address

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 20: Web Services by iFour Technolab Pvt. Ltd.

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

Binding DescriptionBasicHttpBinding Basic Web service communication. No security by

defaultWSHttpBinding Web services with WS-* support. Supports

transactionsWSDualHttpBinding Web services with duplex contract and transaction

support

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 21: Web Services by iFour Technolab Pvt. Ltd.

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

NetPeerTcpBinding Communication between computers across peer-to-peer services. 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

Binding (Cont.)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 22: Web Services by iFour Technolab Pvt. Ltd.

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 attributeMessage 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

Contract

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 23: Web Services by iFour Technolab Pvt. Ltd.

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 serviceData 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 ContractSuppose 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

Contract (Cont.)

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 24: Web Services by iFour Technolab Pvt. Ltd.

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

REST

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 25: Web Services by iFour Technolab Pvt. Ltd.

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

REST (Cont.)

ASP.NET Software Development Companies India

Page 26: Web Services by iFour Technolab Pvt. Ltd.

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

WEB API

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 27: Web Services by iFour Technolab Pvt. Ltd.

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

References

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India

Page 28: Web Services by iFour Technolab Pvt. Ltd.

Questions?

http://www.ifourtechnolab.com/

ASP.NET Software Development Companies India