Tuesday, March 31, 2009

.NET Framework

The .NET Framework has two main components: the common language runtime and the .NET Framework class library. You can think of the runtime as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and other forms of code accuracy that ensure security and robustness. The class library, is a comprehensive, objectoriented collection of reusable types that you can use to develop applications ranging from traditional commandline or graphical user interface (GUI) applications to applications based on the latest innovations provided by ASP.NET, such as Web Forms and XML Web services.

How can you increase SQL performance ?

√ Every index increases the time in takes to perform INSERTS, UPDATES and DELETES, so the number of indexes should not be very much. Try to use maximum 4-5 indexes on one table, not more. If you have read-only table, then the number of indexes may be increased.

√ Keep your indexes as narrow as possible. This reduces the size of the index and reduces the number of reads required to read the index.

√ Try to create indexes on columns that have integer values rather than character values.

√ If you create a composite (multi-column) index, the order of the columns in the key are very important. Try to order the columns in the key as to enhance selectivity, with the most selective columns to the leftmost of the key.

√ If you want to join several tables, try to create surrogate integer keys for this purpose and create indexes on their columns.

√ Create surrogate integer primary key (identity for example) if your table will not have many insert operations.

√ Clustered indexes are more preferable than nonclustered, if you need to select by a range of values or you need to sort results set with GROUP BY or ORDER BY.

√ If your application will be performing the same query over and over on the same table, consider creating a covering index on the table.

√ You can use the SQL Server Profiler Create Trace Wizard with "Identify Scans of Large Tables" trace to determine which tables in your database may need indexes. This trace will show which tables are being scanned by queries instead of using an index.

Primary Key

A primary key is a special candidate key. It is and attribute or minimal set of attributes that not only uniquely identifies a specific occurrence of the entity, but also exists for every occurrence of an entry. The difference between a primary key and any other unique key is that SQL Server automatically uses the primary key definition in various Referential integrity constructs.

In other words, the primary key is a field (or a set of fields) that uniquely identifies each record of a tale. A table have only one key declared as primary. If a primary key consists of more then one column, duplicate values are allowed in one of the columns, but the combination of values from all the columns in the primary key must be unique.

Candidate Key

A candidate key is one that can uniquely identify each row of a table. Generally, a candidate key becomes the primary key of the table. If the table has more than one candidate key, one of them will become the primary key and the rest are called alternate keys.

Monday, March 30, 2009

Finding Web Services

In a simple application, you may already know the URL of the web service you want to use. If so, you can hard-code it or place it in a configuration file. No other steps are required. In other situations, you might want to search for the web service you need at runtime. For example, you might use a standardized service that’s provided by different hosting companies and is not always available at the same URL. Or, you may just want an easy way to find all the web services provided by a trading partner. In both of these situations, you need to use discovery to programmatically locate the web services you need.
Two specifications help in the discovery of a web service:
DISCO (an abbreviation of discovery): The DISCO standard creates a single file that groups a list of related web services. A company can publish a DISCO file on its server that contains links to all the web services it provides. Then clients simply need to request this file to find all the available web services. This is useful when the client already knows a company that it’s offering services and wants to see what web services they expose and find links to the details of its services. It’s not very useful to search for new web services over the Internet, but it may be helpful for local networks where a client connects to the server and can see what and where services are available.
UDDI (Universal Description,Discovery, and Integration): UDDI is a centralized directory where web services are published by a group of companies. It’s also the place where potential clients can go to search for their specific needs. Different organizations and groups of companies may use different UDDI registries. To retrieve information from a UDDI directory or register your components, you use a web service interface.

Discovery is one of the newest and least mature parts of the web service protocol stack. DISCO is supported only by Microsoft and is slated to be replaced by a similar more general standard named WS-Inspection in future .NET releases. UDDI is designed for web services that are intended to be shared publicly or among a consortium of companies or organizations. It’s not incorporated into the .NET Framework, although you can download a separate .NET component to search UDDI directories and register your components (see http://msdn.microsoft.com/library/en-us/uddi/uddi/portal.asp). Because there aren’t yet any well-established UDDI directories, and because many web services are simply designed for use in a single company or between a small set of known trading partners, it’s likely that most web services will not be published in UDDI.

Web Service Standards

WSDL
Used to create an interface definition for a web service. The WSDL document tells
a client what methods are present in a web service, what parameters and return values each method uses, and how to communicate with them.
SOAP
The message format used to encode information (such as data values) before
sending it to a web service.
HTTP
The protocol over which all web service communication takes place. For example,
SOAP messages are sent over HTTP channels.
DISCO
Used to create discovery documents that provide links to multiple web service
endpoints. This standard is Microsoft-specific and will eventually be replaced by a similar standard named WS-Inspection.
UDDI
A standard for creating business registries that catalog companies, the web services
they provide, and the corresponding URLs for their WSDL contracts.

Making Money with Web Services

A new technology is doomed if it does not give new opportunities for the people concerned with making money. From a businessperson’s perspective, web services open new possibilities for the following reasons:
New payment structures: The user of a web service can pay a subscription fee for using the service. One example may be the news feed from Associated Press. Another possibility is a payperview, or micro payment, model. A provider of a credit verification service, for instance, may charge per request.
Real-time interaction and collaboration: Today, data is typically replicated and used locally.Web services enable real-time queries to remote data. An example is an e-commerce site selling computer games. The e-commerce site may hook up to a warehouse to get the number of items in stock in real time. This enables the e-commerce site to provide a better service. Nothing is more frustrating than buying something over the Internet just to learn the next day that the product you wanted is out of stock.
Aggregated services: A web service may aggregate other web services, screen-scraped websites, legacy components exposed using proprietary protocols, and so on. A typical example of an aggregated service is a comparative service giving you the best deal on products. Another type of service is one that groups related services. For example, imagine you’re moving to a new home. Someone could provide you with a service that can update your address at the post office, find the transportation company to move all your possessions, and so on.
Web services are by no means the only technology that can provide these solutions. Many similar solutions are available today using existing technology. However web services have the momentum and standards to make these kinds of services generally available.

Sunday, March 29, 2009

The Benefits of Web Services

Web services are interesting from several perspectives. From a technological perspective, web services try to solve some problems faced when using tightly coupled technologies such as CORBA and DCOM. These are problems such as getting through firewalls, dealing with the complexities of lower-level transport protocols, and integrating heterogeneous platforms. Web services are also interesting from an organizational and economic perspective, because they open doors for new ways of doing business and integrating systems between organizations. DCOM and CORBA are fine for building enterprise applications with software running on the same platform and in the same closely administered local network. They are not fine, however, for building applications that span platforms, span the Internet, and need to achieve Internet scalability. They were simply not designed for this purpose. This is where web services come in. Web services represent the next logical step in the evolution of component-based distributed technologies. Some key advantages include the following:
Web services are simple: That simplicity means they can be easily supported on a wide range of platforms.
Web services are loosely coupled: The web service may extend its interface and add new methods without affecting the clients as long as it still provides the old methods and parameters.
Web services are stateless: A client makes a request to a web service, the web service returns the result, and the connection is closed. There is no permanent connection. This makes it easy to scale up and out to many clients and use a server farm to serve the web services. The underlying HTTP used by web services is also stateless. Of course, it is possible to provide some state by using additional techniques such as the ones you use in ASP.NET web pages, including cookies. However, these techniques aren’t standardized.
Web services are firewall-friendly: Firewalls can pose a challenge for distributed object technologies. The only thing that almost always gets through firewalls is HTTP traffic on ports 80 and 443. Because web services use HTTP, they can pass through firewalls without explicit configuration.

Distributed Computing and Web Services

To fully understand the importance of web services, you need to understand the requirements of distributed computing. Distributed computing is the partitioning of application logic into units that are executed on two or more computers in a network. The idea of distributed computing has been around a long time, and numerous communication technologies have been developed to allow the distribution and reuse of application logic. Many reasons exist for distributing application logic. Some of the most important include the following:
High scalability: By distributing the application logic, the load is spread out to different machines. This usually won’t improve the performance of the application for individual users (in fact, it may slow it down), but it will almost always improve the scalability, thereby allowing the application to serve a much larger number of users at the same time.
Easy deployment: Pieces of a distributed application may be upgraded without upgrading the whole application. A centrally located component can be updated without needing to update hundreds (or event thousands) of clients.
Improved security: Distributed applications often span company or organization boundaries. For example, you might use distributed components to let a trading partner query your company’s product catalog. It wouldn’t be secure to let the trading partner connect directly to your company database. Instead, the trading partner needs to use a component running on your servers, which you can control and restrict appropriately.
The Internet has increased the importance and applicability of distributed computing. The simplicity and ubiquity of the Internet makes it a logical choice as the backbone for distributed applications. Before web services, the dominant protocols were COM (which is called DCOM, or Distributed COM, when used on a network) and CORBA. Although CORBA and DCOM have a lot in common, they differ in the details, making it hard to get the protocols to interoperate.

Limitation Of WebServices

Web services are not limited to the .NET Framework. The standards were defined before .NET was released, and they are exposed, used, and supported by vendors other than Microsoft. The .NET Framework is special because it hides all the plumbing code, and this makes it far easier to expose your own services over the Internet or to access the services provided by other companies. As you’ll see, you don’t need to know all the details of XML and SOAP to successfully program web services (although, of course, some knowledge helps). ASP.NET abstracts the nitty-gritty stuff and generates wrapper classes that expose a simple object-oriented model to send, receive, and interpret the SOAP messages easily.

Saturday, March 28, 2009

The History of Web Services

Even though web services are a new technology, you can learn a lot from recent history. Two of the major shifts in software development over the last couple of decades have been the development ofobject-oriented programming and component-based technology.
Object-oriented programming joined the mainstream in the early 1980s. Many saw objectoriented programming as the solution to the software crisis that resulted from the increasing complexity and size of software applications. Most projects were late and over budget, and the end result was often unreliable. The promise of object-oriented code was that by structuring code into objects, developers could create components that were more reusable, extensible, and maintainable. The 1990s saw the birth of component technology, which made it possible to build applications by assembling components. Component technology is really an extension of object-oriented principles outside the boundaries of any one particular language so that it becomes a core piece of infrastructure that everyone can use. While object-oriented languages allowed developers to reuseobjects in their applications, component-based technologies allowed developers to easily share compiled objects between applications. Two dominant component-based technologies emerged COM (the Component Object Model) and CORBA (Common Object Request Broker Architecture).
Since that time, other component technologies have appeared (such as JavaBeans and .NET), but these are designed as proprietary solutions for specific programming frameworks. Soon after COM and CORBA were created, these standards were applied to distributed components so that an application could interact between objects hosted on different computers in a network. Although both COM and CORBA have a great deal of technical sophistication, they are often difficult to set up and support in network environments, and they can’t work together. These headaches became dramatically worse when the Internet appeared and developers began to apply these technologies to create distributed applications that spanned slower, less reliable, WANs (wide area networks). Because of their inherent complexity and proprietary nature, neither COM nor CORBA became truly successful in this environment. Web services are a new technology that aims to answer these problems by extending component object technology to the Web. Essentially, a web service is a unit of application logic (a component) that can be remotely invoked over the Internet. Many of the promises of web services are the same as those of component technology—the aim is to make it easier to assemble applications from prebuilt application logic, share functionality between organizations and partners, and create more modular applications. Unlike earlier component technologies, web services are designed exclusively for this purpose. This means that as a .NET developer, you will still use the .NET component model to share compiled assemblies between .NET applications. However, if you want to share functionality between applications running on different platforms or hosted by different companies, web services fit perfectly. Web services also place a much greater emphasis on interoperability. All software development platforms that allow programmers to create web services use the same bedrock of open XML-based standards. This ensures that you can create a web service using .NET and call it from a Java client or, alternatively, create a Java web service and call it from a .NET application.

Web Services Overview

While HTML pages (or the HTML output generated by ASP.NET web forms) are meant to be read by the end user, web services are used by other applications. They are pieces of business logic that can be accessed over the Internet. For example, e-commerce sites can use the web service of a shipping and packaging company to calculate the cost of a shipment. A news site can retrieve the news headlines and articles produced by external news providers and expose them on its own pages in real time. A company can even provide the real-time value of their stock options, reading it from a specialized financial or investment site. All of these scenarios are already taking place on the Web, and major Internet companies such as Amazon, Google, and eBay are providing their own web service offerings to third-party developers. With web services, you can reuse someone else’s business logic instead of replicating it yourself, using just a few lines of code. This technique is similar to what programmers currently do with libraries of APIs, classes, and components. The main difference is that web services can be located remotely on another server and managed by another company.