Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
- 2. OverView
What is a Web Service ?
Web Service Technology Stack
WhyWeb Services?
How to create , consume and publish a web service?
What is the difference betweenWeb Services and WCF ?
WCF in detail
SOAPUI
- 3. What is a Web Service ?
Web service is a means by which computers talk to each
other over the web using HTTP and other universally
supported protocols.
A Web service is an application that:
Runs on a Web server ;
Exposes Web methods to interested callers ;
Listens for HTTP requests representing
commands to invoke Web methods ;
Executes Web methods and returns the result.
- 4. Web Service Technology Stack
Web Services are based on:
HTTP (Hypertext Transport Protocol)
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and
Integration)
WS-POLICY (Web Services Policy)
Most Web services expect their Web methods to be
invoked using HTTP requests containing SOAP messages.
SOAP is an XML-based vocabulary for performing
remote procedure calls using HTTP and other protocols.
- 5. Why using web services ?
The benefits of using Web Services:
Exposing the existing function on to network:
Web Services allows you to expose the functionality of your
existing code over the network.
Connecting Different Applications ie
Interoperability:
Web Services allows different applications to talk to each other
and share data and services among themselves. Other
applications can also use the services of the web services.
Standardized Protocol:
Web Services uses standardized industry standard protocol for
the communication.
Low Cost of communication:
Web Services uses SOAP over HTTP protocol for the
communication.
- 6. How to create a web service?
When creating a New Project, under the language of your
choice, select "Web" and then change to .NET Framework 3.5
and you will get the option to create an ASP.NET WEB
Service Application.
- 12. What is the difference between web
services and WCF?
WCF Service supports both http and tcp protocol while
web services support only http protocol
WCF service can be hosted in many ways like on
windows service and self hosting apart from IIS hosting
while web service can be hosted in IIS
WCF has more options for security than web services
- 13. What is the difference between web
services and WCF?
A WCF service can have one or more WCF endpoints thus
one address for each end point . An endpoint is defined by
an address, a binding and a service contract. but a Web
service can have only one address at one point of time
WCF Service is more flexible than web service because it
can very easily change add interfaces end points thus
interacting with a wide range of applications
- 15. • Introduction of WCF
• Discussion about SOA & WCF
• When you should use it.
• What software you need to create a WCF service
• Advantages & Disadvantages of WCF
• Architecture of .Net 3.0 & WCF
• Programming with WCF
• Services (Service Execution Boundaries, WCF & Location Transparencies)
• Contracts (Service, Data, Fault and Message)
• Addresses (TCP, HTTP, IPC, MSMQ and P2P)
• Hosting (IIS, VS2005, Web.Config, Self, Self * Base Addresses, Advanced, ServiceHost<T> and WAS)
• Bindings
• End Points
• Example of WCF & Implementations
- 16. Introduction of WCF
• WCF is a set of .NET technologies (Web services ,.Net Remoting and
enterprises services) for building and running connected systems.
• WCF provides secure, reliable, and transacted messaging along with
interoperability
• WCF applications can be developed in any language which can target the .NET
runtime
• System.ServiceModel is the assembly that contains core functionality for WCF.
• A service is a Common Language Runtime (CLR) type that encapsulates
business functionality and exposes a set of methods that can be accessed by
remote clients.
- 17. When you should use it
• When your business logic has to interact with a variety of client applications.
• When client apps, which are going to use your service, may be written in Java
or .Net.
• You are targeting a distributed computing architecture.
- 18. What software you need to create a WCF service
• Visual studio 2005
• .Net Framework 3.0
• Microsoft Windows Software Development Kit (SDK)
• Visual studio extensions for WCF and WPF
- 19. Advantages of WCF
Known Advantages:
• Makes UI programming & distributed programming very easy.
Reduce complexity by allowing us to focus on single programming model rather than
learn multiple programming models.
• Helps us talk to various applications written in various languages with ease which
means more probable revenues as various applications can start using your core
services with ease.
• Helps us forget about interoperability between various underlying web service
technologies in the past, present and future.
• With WCF, a single service can be defined and exposed over multiple endpoints to
support multiple protocols at the same time.
- 20. Discussion about SOA & WCF
1. What is SOA
SOA is the practice of sequestering the core business functions into independent
services that don’t change frequently. These services are glorified functions that are
called by one or more presentation programs. The presentation programs are volatile
bits of software that present data to, and accept data from, various users.
SOA is nothing more than separating changeable elements from unchangeable
elements.
- 21. 1. Services in WCF
Description
The WCF applications expose the functionality through services. A Service is a Common Language
Runtime(CLR) type that encapsulate business functionality and exposes a set of methods that can be
accessed by remote clients.
A service contract is defined by applying the ServiceContractAttribute to a class or interface. When
applied to a class, the class becomes a service type. When applied to an interface, any class that
implements the interface becomes a service type. In either case, methods exposed by the class or
interface must be decorated with the OperationContractAttribute to be considered part of the service
contract. Methods with this attribute are considered service operations.
A service type must be hosted before clients can invoke service operations.
a) Services' Execution Boundaries
WCF allows the client to communicate with the service across all execution boundaries.
On the same machine , the client can consume services in the same app domain,
across app domains in the same process, or across processes.
- 22. b) WCF & Location Transparency
WCF takes the remote programming model of instantiating and using a proxy and uses
it even in the most local case. Because all interactions are done via a proxy, requiring
the same configuration and hosting ,WCF maintains the same programming model for
the local and remote cases; thus it not only enables you to switch locations without
affecting the client, but also significantly simplifies the application programming
model.
- 23. 2. Addresses
Description:
In WCF, every service is associated with a unique address. The address provides two important
elements: the location of the service and the transport protocol or transport schema used to
communicate with the service. The location portion of the address indicates the name of the target
machine, site, or network; a communication port, pipe, or queue; and an optional specific path or
URI.
a) TCP Addresses
Ex. net.tcp://localhost:8002/MyService.
b) HTTP Addresses
Ex. http://localhost:8001
c) IPC Addresses
Ex. net.pipe://localhost/MyPipe
d) MSMQ Addresses
Ex. net.msmq://localhost/MyService
e) Peer Network Addresses
Peer network addresses use net.p2p for transport, to indicate the use of the Windows peer
network transport. You must specify the peer network name as well as a unique path and port.
- 24. 3. Contracts
Description:
In WCF, all services expose contracts. The contract is a platform-neutral and standard way of
describing what the service does. WCF defines four types of contracts.
a) Service Contracts
Describe which operations the client can perform on the service.
b) Data Contracts
Define which data types are passed to and from the service. WCF defines implicit contracts for
built-in types such as int and string, but you can easily define explicit opt-in data contracts for
custom types
c) Fault Contracts
Define which errors are raised by the service, and how the service handles and propagates errors
to its clients
d) Message Contracts
Allow the service to interact directly with messages. Message contracts can be typed or untyped,
and are useful in interoperability cases and when there is an existing message format you have to
comply with.
- 25. 4. Hosting
Description:
Every WCF service must be hosted in a Windows process called the host process. A single host
process can host multiple services, and the same service type can be hosted in multiple host
processes. The host can be provided by IIS, by the Widows Activation Service (WAS) on
Windows Vista, or by the developer as part of the application.
So each .NET host process can have many app domains. Each app domain can have zero or more
service host instances. However, each service host instance is dedicated to a particular service
type. When you create a host instance, you are in effect registering that service host instance with
all the endpoints for that type on the host machine that correspond to its base addresses. Each
service host instance has zero or more contexts.
- 26. a) IIS Hosting
Hosting in IIS is very similar to hosting a classic ASMX web service. You need to create a virtual
directory under IIS and supply a .svc file. The .svc file functions similar to an .asmx file, and is
used to identify the service code behind the file and class.
b) Using VS 2005
You can use Visual Studio 2005 to generate a boilerplate IIS-hosted service. From the File menu,
select New Website and then select WCF Service from the New Web Site dialog box. This causes
Visual Studio 2005 to create a new web site, service code, and matching .svc file. You can also use
the Add New Item dialog to add another service later on.
c) Web.Config file
The web site config file (Web.Config) must list the types you want to expose as services. You need
to use fully qualified type names, including the assembly name.
<system.serviceModel> <services> <service name = "MyNamespace.MyService"> ... </service>
</services> </system.serviceModel>
d) Self Hosting
Self-hosting is the name for the technique used when the developer is responsible for providing
and managing the life cycle of the host process. Self-hosting is used both in the case of wanting a
process (or machine) boundary between the client and the service, and when using the service in-proc—
that is, in the same process as the client.
- 27. e) Self Hosting & Base Addresses
You can launch a service host without providing any base address by omitting the base
addresses altogether.
f) Advanced Hosting Features
The ICommunicationObject interface supported by ServiceHost offers some advanced
features.
g) ServiceHost<T> Class
You can improve on the WCF-provided ServiceHost class by defining the
ServiceHost<T> class.
h) WAS Hosting
The Windows Activation Service (WAS) is a system service available with Windows
Vista. WAS is part of IIS7, but can be installed and configured separately. To use the
WAS for hosting your WCF service, you need to supply a .svc file, just as with IIS. The
main difference between IIS and WAS is that the WAS is not limited to HTTP and can be
used with any of the available WCF transports, ports, and queues.
- 28. 5. Bindings
Description
WCF groups together a set of communication aspects in bindings. A binding is
merely a consistent, canned set of choices regarding the transport protocol,
message encoding, communication pattern, reliability, security, transaction
propagation, and interoperability. You can use the WCF-provided bindings as is, you
can tweak their properties, or you can write your own custom bindings from scratch.
A single service can support multiple bindings on separate addresses.
a) Standard Bindings
WCF defines nine standard bindings:
• Basic Binding
• TCP Binding
• P2P Binding
• IPC Binding
• WS Binding
• Federated WS Binding
• Duplex WS Binding
• MSMQ Binding
• MSMQ Integration Binding
- 29. A binding describes the protocols supported by a particular endpoint, specifically, the
following:
• The transport protocol, which can be TCP, named pipes, HTTP, or MSMQ
• The message encoding format, which determines whether messages are serialized
as binary or XML, for example
• Other messaging protocols related to security and reliability protocols, plus any
other custom protocols that affect the contents of the serialized message
- 30. 6. End Points
Every service is associated with an address that defines where the service is, a binding that
defines how to communicate with the service, and a contract that defines what the service
does. The endpoint is the fusion of the address, contract, and binding (ABC)
Address :- The address is obviously the location of the service, such as
‘net.pipe://localhost/LocalTimeService’
Binding:- The binding specifies security options, encoding options, and transport
options.
Contract:- the contract is the actual interface that the service implements.
Every endpoint must have all three elements, and the host exposes the endpoint. Logically
Every service must expose at least one business endpoint and each endpoint has exactly
one contract. All endpoints on a service have unique addresses, and a single service can
expose multiple endpoints. These endpoints can use the same or different bindings and can
expose the same or different contracts. There is absolutely no relationship between the
various endpoints a service provides.
- 31. Example :-
<endpoint name ="LocalTimeService“
address="net.pipe://localhost/LocalTimeService" binding="netNamedPipeBinding“
contract="ILocalTime" />
- 33. What is soapUI?
• SoapUI is a free and open source cross-platform Functional Testing solution.
With an easy-to-use graphical interface, and enterprise-class features, SoapUI
allows you to easily and rapidly create and execute automated functional,
regression, compliance, and load tests. In a single test environment, SoapUI
provides complete test coverage and supports all the standard protocols and
technologies. There are simply no limits to what you can do with your tests.
- 34. Features:
• Functional Testing
• Security Testing
• Load Testing
• Technology Support
• Automation
• Analytics
• Recording
- 35. Functional Testing
• Drag and Drop Test Creation
• Data-Driven Testing
• Multi Environment Support
- 37. Load Testing
• Real-Time, Interactive Distributed Testing
• Drag and Drop Test Creation
• Integrated Analytics