Developing and Deploying Web Services in.net
Facts about.net.net Framework (pronounced dot net) is a software framework developed by Microsoft that runs primarily on Microsoft Windows. Microsoft started development of.net Framework in the late 1990s, originally under the name of Next Generation Windows Services (NGWS). By late 2000, the first beta versions of.net 1.0 were released.
Brief Overview.NET Framework includes a set of standard class libraries. The class library is organized in a hierarchy of namespaces.these class libraries implement a large number of common functions, such as file reading and writing, graphic rendering, database interaction, and XML document manipulation, among others..net class libraries are available to all CLI compliant languages..net Framework class library is divided into two parts: Framework Class Library (FCL) and Base Class Library (BCL). FCL includes a small subset of the entire class library and is the core set of classes that serve as the basic API of CLR. Classes in mscorlib.dll and some classes in System.dll and System.core.dll are part of FCL. BCL is a superset of FCL and refers to the entire class library that ships with.net Framework. It includes an expanded set of libraries, including Windows Forms, ADO.NET, ASP.NET, Language Integrated Query (LINQ), Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF) and Workflow Foundation (WF). BCL is much larger in scope than standard libraries for languages like C++, and comparable in scope to standard libraries of Java. FCL provides user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. Programmers produce software by combining their own source code with.net Framework and other libraries.
Brief Overview Programs written for.net Framework execute in a software environment known as Common Language Runtime (CLR), an application virtual machine that provides services such as security, memory management, type safety, garbage collection, thread management, exception handling and interoperability. Common Language Runtime is Microsoft s implementation of Common Language Infrastructure (CLI) which provides a language-neutral platform for application development and execution. For computer programs to run on CLI, they need to be compiled into Common Intermediate Language (CIL) as opposed to being compiled into machine code. Upon execution, an architecture-specific Just-in-time compiler (JIT) turns the CIL code into machine code. To improve performance, however,.net Framework comes with Native Image Generator (NGEN) that performs ahead-of-time compilation.
Brief Overview FCL and CLR together constitute.net Framework and can support the following design tenets: Interoperability Because computer systems commonly require interaction between newer and older applications,.net Framework provides means to access functionality implemented in newer and older programs that execute outside.net environment. Language independence.net Framework introduces a Common Type System (CTS) that defines all possible datatypes and programming constructs supported by CLR and how they may or may not interact with each other conforming to CLI specification. Because of this feature,.net Framework supports the exchange of types and object instances between libraries and applications written using any conforming.net language. Portability While Microsoft has never implemented the full framework on any system except Microsoft Windows, it has engineered the framework to be platform-agnostic, and cross-platform implementations are available for other operating systems.
Security.NET Framework has its own security mechanism with two general features: Code Access Security (CAS), and validation and verification Memory management Brief Overview CLR frees the developer from the burden of managing memory (allocating and freeing up when done); it handles memory management itself by detecting when memory can be safely freed. Instantiations of.net types (objects) are allocated from the managed heap; a pool of memory managed by CLR. As long as there exists a reference to an object, which might be either a direct reference to an object or via a graph of objects, the object is considered to be in use. When there is no reference to an object, and it cannot be reached or used, it becomes garbage, eligible for collection..net Framework includes a garbage collector (GC) which runs periodically, on a separate thread from the application's thread, that enumerates all the unusable objects and reclaims the memory allocated to them. It is a non-deterministic, compacting, mark-and-sweep garbage collector. GC runs only when a certain amount of memory has been used or there is enough pressure for memory on the system.
Brief Overview Simplified deployment.net Framework includes design features and tools which help manage the installation of computer software to ensure that it does not interfere with previously installed software, and that it conforms to security requirements. Performance When an application is first launched, the.net Framework compiles the CIL code into executable code using its justin-time compiler, and caches the executable program into the.net Native Image Cache. Due to caching, the application launches faster for subsequent launches, although the first launch is usually slower. To increase speed of the first launch, developers may use the Native Image Generator utility to manually compile and cache any.net application, ahead-of-time.
ASP.NET Asp.net is an open source server-side Web application framework designed for Web development to produce dynamic Web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the.net Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP. NET code using any supported.net language. The ASP.NET SOAP extension framework allows ASP.NET components to process SOAP messages. Microsoft recommends dealing with dynamic program code by using the code-behind model, which places this code in a separate file or in a specially designated script tag. This practice is automatic in Microsoft Visual Studio and other IDEs. In theory, this would allow a Web designer, for example, to focus on the design markup with less potential for disturbing the programming code that drives it. This is similar to the separation of the controller from the view in Model View Controller (MVC) frameworks.
ASP.NET ASP.NET aims for performance benefits over other script-based technologies (including classic ASP) by compiling the server-side code the first time it is used to one or more DLL files on the Web server. These dll files or assemblies contain Microsoft Intermediate Language (MSIL) for running within the common language runtime; this provides a performance boost over pure scripted languages and is similar to the approach used by Python and not dissimilar to java server pages. This compilation happens automatically the first time a page is requested. However, the compilation might cause a noticeable but short delay to the Web user when the newly edited page is first requested from the Web server, but will not again unless the page requested is updated further. The ASPX and other resource files are placed in a virtual host on an Internet Information Services server (or other compatible ASP.NET servers). The first time a client requests a page, the.net Framework parses and compiles the file(s) into a.net assembly and sends the response; subsequent requests are served from the DLL files. By default ASP.NET will compile the entire site in batches of 1000 files upon first request. If the compilation delay is causing problems, the batch size or the compilation strategy may be tweaked. Developers can also choose to pre-compile their "codebehind" files before deployment, using Microsoft Visual Studio, eliminating the need for just-in-time compilation in a production environment. This also eliminates the need of having the source code on the Web server.
WCF Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data. A few sample scenarios include: A secure service to process business transactions A chat service that allows two people to communicate or exchange data in real time A Silverlight application to poll a service for the latest data feeds
Features of WCF (½) Service Orientation Service-oriented architecture, SOA Interoperability Multiple Message Patterns Service Metadata WSDL, WS-MetadataExchange, WS-Policy, and WS-SecurityPolicy Data Contracts (serialization engine) Extensibility
Features of WCF (2/2) Security SSL or WS-SecureConversation Multiple Transports and Encodings: any of several built-in transport protocols and encodings most common protocol and encoding is to send text SOAP messages using (HTTP) Reliable and Queued Messages Durable Messages Transactions: WS-AtomicTransactions Microsoft Distributed Transaction Coordinator AJAX and REST Support
Securing WCF(½) Transport security When using transport security the user credentials are passed using the transport layer so the message will not be protected unless it travels across a secure network. It is used to provide security between two endpoints (service and client) and if there are intermediary systems between the client and service, each intermediate point must forward the message over a new secure connection. A well-known transport security mechanism is SSL/TLS which is used for HTTPS, SSH and many others. You use transport security in the following scenarios: 1. You are sending a message directly from your application to a WCF service and the message will not be routed through intermediate systems. 2. Both the service and the client are located in an intranet.
Securing WCF(2/2) Message security Message security focuses on ensuring the integrity and privacy of individual messages, without regard for the network. Through mechanisms such as encryption and signing via public and private keys, the message will be protected even if sent over an unprotected transport e.g. plain HTTP. You use message security in the following scenarios: 1. You are sending a message to a WCF service, and the message is likely to be forwarded to other WCF services or may be routed through intermediate systems. 2. Your WCF clients are accessing the WCF service over the Internet.
WS-AtomicTransaction If the server and client are written using WCF, you do not need to use WS-AT. Instead, you can use the default settings of NetTcpBinding with the TransactionFlow attribute enabled Web Services Discovery You can use the Web Services Discovery tool (Disco.exe) from a command prompt to perform Web service discovery on a URL.
Difference between Web Service in ASP.net & WCF WCF is a replacement for all earlier web service technologies from Microsoft. It also does a lot more than what is traditionally considered as "web services". Using WCF "web services" you will get a much higher degree of flexibility and portability doing things in WCF than through traditional ASMX because WCF is designed, from the ground up, to summarize all of the different distributed programming infrastructures offered by Microsoft. An endpoint in WCF can be communicated with just as easily over SOAP/XML as it can over TCP/binary and to change this medium is simply a configuration file mod. ASMX is older than WCF, and anything ASMX can do so can WCF (and more). Web Services can be accessed only over HTTP & it works in stateless environment, where WCF is flexible because its services can be hosted in different types of applications. Common scenarios for hosting WCF services are IIS,WAS, Self-hosting, Managed Windows Service. The major difference is that ASP.net Web Services Use XmlSerializer. But WCF Uses DataContractSerializer which is better in Performance as compared to XmlSerializer.
WCF ASP.NET Web Services Supports various protocols like HTTP, HTTPS and TCP (Multicasting using UDPBinding in WCF 4.5) Supports only HTTP, HTTPS protocols. Hosted in IIS, WAS(Windows Activation Service), Self-hosting, Windows Service. Hosted only in IIS. Supports security, reliable messaging, transaction and AJAX and REST supports. Support security but is less secure as compared to WCF. For security, normally we use Username/Password. Supports DataContract serializer by using System.Runtime. Serialization. Supports XML serializer by using System.Xml.Serialization. Supports One-Way, Request-Response and Duplex service operations. Supports One-Way and Request-Response service operations. WCF are faster than ASP.NET Web Services. ASP.NET Web Services are slower than WCF Hash Table can be serialized. Hash Table cannot be serialized. Only public properties/fields can be serialized. Unhandled Exceptions does not return to the client as SOAP faults. Unhandled Exceptions returns to the client as SOAP faults. WCF supports better exception handling by using FaultContract. Supports XML, MTOM, Binary message encoding. Supports multi-threading by using ServiceBehaviour class. Supports XML and MTOM (Message Transmission Optimization Mechanism) message encoding. Doesn t support multi-threading.