22
Prepared By: Mr. Dhrumil Patel iFour Consultancy Web Services

Understanding Web Services by software outsourcing company india

Embed Size (px)

Citation preview

Page 1: Understanding Web Services by software outsourcing company india

Prepared By:Mr. Dhrumil Patel

iFour Consultancy

Web Services

Page 2: Understanding Web Services by software outsourcing company india

Web Service is 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.

WebService is language independent and Web Services communicate by using standard web protocols and data formats, such asHTTPXMLSOAP

Introduction to Web Service

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 3: Understanding Web Services by software outsourcing company india

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.)

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 4: Understanding Web Services by software outsourcing company india

SOAP (simple object access protocol) is a remote function calls that invokes method and execute 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

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 5: Understanding Web Services by software outsourcing company india

SOAP and XML created the solution for the problem that developers were facing before. SOAP is a standard XML based protocol that communicated over HTTP.

We can think of SOAP as message format for sending messaged between applications using XML. It is independent of technology, platform and is extensible too.

We have SOAP and XML to give us connectivity between applications. Does it mean that I have to write XML and SOAP specific things myself to facilitate this

communications? I could do that but that will be very time consuming and sometimes error prone too.

Where does Web Services come in picture? Well, Web services is the mechanism that ASP.NET framework provides to make it easy for us to write code to facilitate connectivity between applications.

SOAP (Cont.)

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 6: Understanding Web Services by software outsourcing company india

WSDL stands for Web Service Description Language, a standard by which a web service can tell clients what messages it accepts and which results it will return.

WSDL 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).

WSDL 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

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 7: Understanding Web Services by software outsourcing company india

WSDL Components

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 8: Understanding Web Services by software outsourcing company india

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.)

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 9: Understanding Web Services by software outsourcing company india

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 attribute. 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. A part may represent a parameter in the message; the bindings define the actual meaning of the part. Messages were removed in WSDL 2.0, in which XML schema types for defining bodies of inputs, outputs and faults are referred to simply and directly.

Types Types Describes the data. The XML Schema language (also known as XSD) is used (inline or referenced) for this purpose.

WSDL Components (Cont.)

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 10: Understanding Web Services by software outsourcing company india

Windows Communication Foundation (Code named Indigo) is a programming platform and runtime system for building, configuring and deploying network-distributed services.

It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF.

It is unified programming model provided in .Net Framework 3.0. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.

WCF

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 11: Understanding Web Services by software outsourcing company india

WCF is interoperable with other services when compared to .Net Remoting where the client and service have to be .Net.

WCF services provide better reliability and security in compared to ASMX web services. In WCF, there is no need to make much change in code for implementing the security

model and changing the binding. Small changes in the configuration will make your requirements.

WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.

Advantages of WCF

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 12: Understanding Web Services by software outsourcing company india

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

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 13: Understanding Web Services by software outsourcing company india

A WCF Service is composed of three components :1) Service Class - A WCF service class implements some service as a set of methods. 2) Host Environment - A Host environment 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. 3) 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

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 14: Understanding Web Services by software outsourcing company india

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

http://localhost/WCFServiceSample/Service.svc

Address

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 15: Understanding Web Services by software outsourcing company india

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

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 16: Understanding Web Services by software outsourcing company india

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 defaultWSHttpBinding Web services with WS-* support. Supports transactions

Binding (Cont.)

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 17: Understanding Web Services by software outsourcing company india

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:1.) Service Contract

Service contracts describe the operation that service can provide. For Eg, 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.

2.) Message Contract Default SOAP message format is provided by the WCF runtime for communication between

Client and service. If it is not meeting your requirements then we can create our own message format. This can be achieved by using Message Contract attribute.

Contract

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 18: Understanding Web Services by software outsourcing company india

3.) Data ContractData contract 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.

4.) Fault ContractSuppose the service I consumed is not working in the client application. I want to know the

real cause of the problem. How I 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.)

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 19: Understanding Web Services by software outsourcing company india

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

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 20: Understanding Web Services by software outsourcing company india

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, for example ‘http://www.microsoft.com/Surface-Pro-3’ is a resource Request Verbs – These describe what you want to do with the resource. 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 – These are 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. For 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 – This is the 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.)

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 21: Understanding Web Services by software outsourcing company india

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

eCommerce Solution Providershttp://www.ifourtechnolab.com

Page 22: Understanding Web Services by software outsourcing company india

Thank you

Software development company indiahttp://www.ifourtechnolab.com