This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
Visual Studio .NET: Build Web Applications Faster and Easier Using Web Services and XML
Figure 1 illustrates the relationship between the topics I'll cover. As with all product previews, details are subject to change before the product ships, but the information in the article should help you start thinking about how to take advantage of all these great new features.
Web Services and the Microsoft .NET FrameworkAs the Web is evolving and technologies for universal data exchange such as XML are beginning to proliferate, a new development paradigm has emerged where software is seen as a collection of readily available Web Services that can be distributed and accessed via standard Internet protocols. Web Services provide middle-tier business functionality exposed via standard Web protocols. Since they use HTTP as a transport, they allow remote method requests to pass through enterprise firewalls. For security, both Secure Sockets Layer (SSL) and standard authentication techniques are supported. Using XML to invoke and return data from these Web Services means that programs written in any language, using any component model, and running on any operating system can access this functionality.
Obviously, the advantages of the model are many. Not only can companies more easily integrate internal applications, but they can also access services exposed by other businesses. By combining Web Services exposed on the Internet, companies can create a wide variety of value-added applications. For example, a company could unify banking, electronic bill payment, stock trading, and insurance services into a single, seamless financial management portal. Or they could integrate inventory control, fulfillment mechanisms, and purchase order tracking into a comprehensive supply chain management system.
While the Web Services model does not require any particular platform for hosting, being able to easily deploy and maintain a Web Service capable of supporting millions of clients requires the proper infrastructure. The MicrosoftÂ® .NET Framework has been designed to provide the tools and technologies necessary to support that infrastructure. In short, the framework is an extension of WindowsÂ® DNA 2000 with specific support for service delivery, service integration, and long running operations.
The heart of the Microsoft .NET Framework is a common language runtime that manages the needs of running code written in any Visual Studio programming language. This runtime supplies many services that help simplify code development and application deployment while also improving application reliability. The framework also supplies a set of class libraries that developers can use from any programming language. The framework provides specific support for building traditional Windows-based applications, Web applications, Web Services, and components. For more information on the Microsoft .NET Framework, read Mary Kirtland's article "The Programmable Web: Web Services Provides Building Blocks for the Microsoft .NET Framework," in this issue.
In Visual Studio .NET, you can easily expose any functionâ"in any languageâ"as a Web Service. There is no need to learn XML and SOAP to take advantage of Web Services. When you compile your business objects, Visual Studio .NET will automatically generate an XML file that describes the function, and when it is called the function will automatically send and receive XML packets.
After the Web Service has been built, both the compiled code and the XML file describing the public methods of the service are published to the Web server. The Web Service can now be invoked via HTTP, and XML will automatically be used to pass data to and from the service.
In Visual Studio .NET, you can drag any exposed Web Service directly into your application. Doing so enables Visual Studio to treat the Web Service as a class. Calling the Web Service is as simple as creating a new instance of the Web Service class and then calling its exposed methods.
A Web Services ExampleLet's take a look at an example of how you can assemble an application from Web Services. This example uses Visual Basic, but the same tools for simplifying Web Service creation are available in other language products in Visual Studio. The Web Service in this example performs stock ratings.
First you would create a new Web Service project in Visual Basic called Stocks, as shown in Figure 2. Next, you would add a new class, called Ratings, to the project and write the code for the function to call the service, as shown in Figure 3.
When you build the project, Visual Studio automatically creates an XML file that describes the Rate function, as follows:
To use a Web Service, all you need to do is drop the Web Service XML file into a project since it contains the URL of the Web Service as well as all the functions that are available. Visual Studio automatically creates the plumbing necessary to call the service.
Notice in Figure 5 that the stock rating service XML file has been included in the project. Visual Studio can now provide full statement completion when you access the Web Service. The stock rating service could also have been created on any operating system, including flavors of Unix, with any Web server, including Apache. However, using Microsoft Windows 2000 and Internet Information Services (IIS) 5.0 will make creating and assembling these services very easy and automatic.
New Features of the Visual Studio .NET IDEVisual Studio .NET has a new, almost completely customizable shell that brings Visual Basic, Visual C++Â®, and Visual FoxProÂ® into a common integrated development environment (IDE). Because Web development deeply permeates Visual Studio .NET, the functionality originally found in Visual InterDevÂ® is now a core part of the environment itself and is accessible from the various language products. Regardless of the language chosen for development, there is now just one environment to learn, configure, and use. You don't have to switch back and forth between environments to build, debug, and deploy your code. The net result is faster, easier development of enterprise applications. Whether you're building single language applications or creating mixed-language solutions, the common IDE supports high productivity development via drag and drop visual designers for HTML, XML, data, server-side code, and more.
In addition, the common IDE provides end-to-end debugging of Web applications across languages, projects, processes, and stored procedures. My favorite new features, which I'll describe later, include Dynamic Help, the Visual Web Page Editor, the Task List, the Object Browser, the new Command window functionality, Visual Basic for Applications (VBA) integration, Auto-Hide windows, multiple monitor support, and Office-style menus. Some of the new features are highlighted in Figure 6.
In order to find the right information at the right time from the MSDNÂ® library, the Visual Studio IDE can now display links to related documentation (including MSDN Magazine articles!) based on the features or technologies currently in use. For example, you're in the IDE but don't have an application or component open, the environment displays links to information on how to plan an application, a selection of common business templates and wizards, and a dynamic list of application templates from various vendors. As you progress through the creation of your application, the IDE knows what part of the application you are working on and displays appropriate content in the Dynamic Help window.
The new Visual Web Page Editor is a shared WYSIWYG Web page editor that provides a graphical way to develop Web pages without delving into HTML or script code. The Web Page Editor provides a number of helpful facilities such as HTML tag and statement completion, design-time syntax-checking of XML, and absolute positioning of elements.
The Task List feature, formerly available only to developers working in Visual C++, now works across all Visual Studio-based languages and projects and allows developers to mark their code with comments related to tasks they need to do. These tasks are parsed and displayed in an easy tabular format in the Tasks window. This feature makes it easy for you to annotate your code so that when you or another member of your team opens it later, the exact state of the code can be understood with minimal pain. Double-clicking on the code comment in the Task List displays the section of code containing the comment.
An object browser is nothing new to programmers who use Visual Basic, but the new Object Browser for Visual Studio maps all objects on the system and provides detailed information about each. You can search for the information you need using the Object Browser's advanced filtering, sorting, and grouping features regardless of the language used to develop the object.
The Command Window allows you to more quickly harness the power of the IDE by providing a single input line to find, navigate, and execute the many possible elements within and outside the IDE. If you prefer the keyboard, you can utilize the Command Window as a method to perform searches, navigate to windows and items within a solution, execute commands, navigate the Web, and run external programs. The IDE's IntelliSenseÂ® feature has been extended to the Command Window where it suggests a match based on entries you have typed previously.
The IDE is now completely customizable and extensible using VBA macro recording and programming. Almost the entire range of IDE sub-systems are available for customization and automation. The addition of VBA support simplifies the process of integrating other tools or applications (such as Microsoft Project or OutlookÂ®) into the development cycle. On-the-fly customization and invocation of macros can be coded in the Command Window for an additional level of control.
With the move toward cross-language projects, Visual Studio .NET supports debugging across multiple languages contained in one solution. Using the debugger, developers can step seamlessly between HTML, script, and codeâ"complete with integrated call stacksâ"offering a total solution for end-to-end development.
Another great new productivity feature in Visual Studio .NET is Auto-Hide windows. When you are finished using a window such as the toolbox, it simply collapses to the side of the screen. When you're ready to use it again, simply move your mouse over the collapsed window to expand it. This feature works with all of the shared windows so that you can have the maximum amount of screen real estate as you code. Another way to get additional real estate is by adding monitors; Visual Studio .NET now fully supports multiple monitor configurations.
Visual Studio also implements a feature you may have seen in Office 2000: menus that hide the least-used menu options. If you need to get to a hidden menu option, simply hold the mouse over the menu for one second to see the complete list of menu options. These settings are all user configurable so that you can turn off the productivity features that you don't need.
New Features in Visual Basic .NETTo rapidly build enterprise Web applications, developers must rely on business logic that is scalable, robust, and reusable. Over the past several years, object-oriented programming has emerged as the primary methodology for building systems that meet these requirements. Using object-oriented programming languages helps make large-scale systems easier to understand, simpler to debug, and faster to update.
While Visual Basic is a popular tool for rapid development of Windows-based applications, its lack of object-oriented language features sometimes limited its acceptance for creating middle-tier components. To address this issue, the upcoming release of Visual Basic has object-oriented language features to simplify the development of enterprise Web applications. With these new language features, Visual Basic delivers the power of C++ or the Java language while maintaining the instant accessibility that has made it such a popular development tool. I'll briefly describe new support in Visual Basic for inheritance, overloading, polymorphism, error handling with tryï¿½catchï¿½finally, and freethreading. For a full treatment of new features in Visual Basic, see "The Future of Visual Basic: Web Forms, Web Services, and Language Enhancements Slated for Next Generation," by Joshua Trupin in the April 2000 issue of MSDN Magazine.
The most requested feature for Visual Basic has been support for implementation inheritance. In the upcoming release, Visual Basic has a new Inherits keyword to facilitate implementation inheritance as part of a class definition.
The new version of Visual Basic also supports overloading. Overloading allows an object's methods and operators to have different meanings depending on its context. Operators can behave differently depending on the data type, or class, of the operands. For example, x+y can mean different things depending on whether x and y are integers, strings, or structures. Overloading is especially useful when your object model dictates that you employ similar names for procedures that operate on different data types. A class that can display several different data types could have Display procedures that look like this:
Polymorphism refers to the ability of Visual Basic to process objects differently, depending on their data type or class. Additionally, it provides the ability to redefine methods for derived classes. For example, given a base class of Employee, polymorphism enables the programmer to define different PayEmployee methods for any number of derived classes, such as Hourly, Salaried, or Commissioned. No matter what type of an Employee an object is, applying the PayEmployee method to it will return the correct results, as shown in the following example:
With the new try...catchï¿½finally functionality of Visual Basic, these problems go away. Exception handling can be nested and there is a control structure for writing cleanup code that executes in both normal and exception conditions.
Visual Basic code today is synchronous, meaning that each line of code must be executed before the next one, but when developing Web applications, scalability is key and developers need tools that enable concurrent processing. The new version of Visual Basic implements freethreading. With the inclusion of freethreading, developers can spawn a thread (which can then perform some long-running task, execute a complex query, or run a complex calculation) while the rest of the application continues synchronously.
New Features in C++Starting with Visual Studio .NET, the basic C++ language has been extended to provide support for programming to the new Microsoft .NET Framework. New to C++ are Managed Extensions, which are a set of upward compatible keywords and attributes that provide a familiar way to migrate an existing C++ application to the Microsoft .NET Framework. With a single compile, you can begin accessing the features of the framework without having to give up any of the traditional benefits of C++ that you have come to love, such as custom memory allocation, direct access to the Windows APIs, and efficient manipulation of low-level machine details.
Using data that conforms to the new Unified Type System makes any class you create in C++ immediately accessible in any other language in Visual Studio that targets the Microsoft .NET Framework. Inheritance across languages is finally possible.
Memory management has also been enhanced. Managed Extensions provide access to a garbage-collected memory heap and automatically manage objects allocated from this heap. Garbage collection means an automatic performance boost for most applications and allows the developer to focus on more important aspects of the application instead of the management of objects and pointers. Watch for more information about new C++ features in upcoming issues of MSDN Magazine.
A New Language: C#C# is an elegant, simple, type-safe, object-oriented language designed to bring rapid application development (RAD) to the C and C++ developer without sacrificing the power and control that has been a hallmark of C/C++. Since Joshua Trupin's article, "Get Sharp this Summer: C# Offers Power of C++ and Simplicity of Visual Basic," in this issue provides details and examples, I'll just summarize a few of the key features of C#:
New Features for Enterprise DevelopmentThe new Visual Studio Enterprise Frameworks (VSEF) provide organizations with the ability to define project policies and best practices, then communicate them from within the Visual Studio IDE to enforce adherence to architectural and technology decisions. There are two primary components to VSEF: Enterprise Templates and Policy Definition.
Enterprise Templates enable organizations to create standard templates for common solutions. A multitiered architecture such as Windows DNA 2000 can be captured at a high level as a solution containing specific project types at each of the logical application tiers. Microsoft provides a number of these templates with Visual Studio, including Windows DNA and Web Services templates. An additional benefit to developers and organizations is the extensibility of these templates. Templates are completely customizable using an XML schema to meet the specific needs of an organization.
The second primary feature delivered as part of VSEF is policy definition. Policy definition lets organizations filter the menu, dialog, and component choices available within the IDE. These policy definitions can be attached to architectural templates, allowing developers to more easily match specified business practices. For example, in the Windows DNA template, the business logic project should not contain any user interface components, so an architect might define a policy that says Web Forms and Win Forms cannot be used in that particular project. Architects can take this process even further and narrow the choices for specific technologies such as data access mechanism, default properties or settings, and appropriate ranges for properties. By narrowing the implementation details to appropriate technologies and choices, VSEF provides a more productive environment for developers and a higher likelihood of success in their application development projects.
The combination of Enterprise Templates and Policy Definition enables organizations to create a set of best practices and to communicate them with their developers in an efficient and effective manner. Customers can extend the VSEF features further by including links to custom topics and information that is viewable in the Dynamic Help window. For example, an organization may decide to standardize on ActiveXÂ® Data Objects (ADO) as their data access methodology and enforce this decision through a policy definition that they can attach to an architecture template. The organization can include information that explains the policy and why it exists. When a developer is implementing data access code and has questions about what the policy is and why it exists, he will be able to select the link in the Dynamic Help window to view the corporate policy.
Web FormsThe next version of Visual Studio introduces a new technology called ASP+ Web Forms that simplifies the development of scalable Web applications. Modeled after forms in Visual Basic, Web Forms allow developers to rapidly develop cross-platform, cross-browser, programmable Web applications using the very same techniques already used in Visual Basic to build form-based desktop applicationsâ"drag controls to a form, double-click on a control, write some code, and press F5 to run the application.
A standard Web Forms page consists of an HTML file containing the visual representation of the page and a source file with event-handling code. The source is compiled into executable code, providing fast runtime performance. Both files reside and execute on the server where they generate an HTML 3.2-compliant document that's sent to the client.
The advantage of Web Forms over ASP pages and WebClasses is that Web Forms implement the full Visual Basic or C# language (or any compliant language) on the server. The code compiles and executes on the server for maximum performance and scalability. Additionally, Web Forms are more maintainable because they cleanly separate user interface (the HTML file) from code (a class file). Today, ASP code requires you to commingle HTML and script code on a page. With Web Forms, developers can write all the code while offloading the HTML file design to a graphic artist.
Web Forms also enable applications to run on any browser on any platform. You can build pages that are pure HTML 3.2 or you can specify a particular browser target.
Managing Web Application Data with ADO+ADO+ is an improvement to ADO that provides platform interoperability and scalable data access. Because XML is the format for transmitting data, any application that can read the XML format can process data. In the most extreme case, the receiving component need not be an ADO+ component at all. It might be a Visual Studio-based solution or any application running on any platform. ADO+ was expressly built with these scenarios in mind.
Datasets are new to ADO+. A dataset is an in-memory copy of database data that contains any number of data tables, each of which typically corresponds to a database table or view. A dataset constitutes a disconnected view of the database data. That is, the data set exists in memory without an active connection to a database containing the corresponding tables or views to support the needs of Web applications.
At runtime, data will be passed from the database to a middle-tier business object and then down to the user interface. The data exchange uses an XML-based persistence and transmission format. To transmit data from one tier to another, an ADO+ solution expresses the in-memory data (the dataset) as an XML file and then sends the XML file to the other component. You can navigate and manipulate the data as an XML tree and use schema to view the XML data relationally. Figure 7 illustrates the major components of an ADO+ solution.
In Visual Studio .NET, it is possible to program against your data objects, rather than against tables and columns. For example, consider the following line of code, using conventional (not strongly typed) programming:
There are a host of new features to make working with the XML data easy in Visual Studio .NET. For instance, for the hardcore XML developer there is a color-coded XML editor with statement and tag completion as shown in Figure 9.
You can also interact with a graphical view of data using the design view of the Dataset Designer, shown in Figure 10. Simply drag and drop tables from any data source, including SQL Serverâ¢ and Oracle databases, from the Server Explorer to the design surface. You can create datasets that are made up of data from any source, including relational databases, data entities created during design time, and even XML files.
Often you need to add, modify, or delete data while you are designing your application. From the Data Preview tab, you can not only add and modify data, but also navigate the relationships of your data, as shown in Figure 11.
The data binding technologies for Visual Studio .NET have also been dramatically improved to take full advantage of ADO+, so building user interfaces that interact with data is easy. More importantly, you can now bind values to business objects and Web Services.
RAD for the ServerThe key to building scalable Web applications is to focus on the middle tier. The business logic and the bulk of the application occur on middle-tier servers. The next version of the Visual Studio development system provides several new features including the Server Explorer and the Component Designer. They allow the same RAD using reusable server components that developers who use Visual Basic have used to rapidly assemble Windows-based user interfaces, applying this technique to the construction of middle-tier objects.
One of the biggest challenges in writing a middle-tier component is discovering what application services are available on the corporate network. And they can be very difficult to integrate into your application components.
If you have used Visual Studio 6.0, you know that discovery of Microsoft SQL Server and Oracle databases was enabled, and Visual Studio could manipulate the schema and data in those databases. Using the Data View window, you could point to a database and then expand nodes to drill down into the structure of the database and even modify the structure of the database or the tables, views, and stored procedures.
The next version of Server Explorer takes a giant step forward from the Visual Studio 6.0 Data View and shows the resources from an entire computerâ"including databases, message queues, and all other installed server elements that live there (see Figure 12).
You can also use Server Explorer to perform administrative tasks on your server resources. For example, you can add, delete, or rename a message queue, or start and stop a Windows NTÂ® service from within the Visual Studio IDE.
For example, you might choose a specific message queue and drag and drop it to the design surface in the Component Designer. Visual Studio will automatically create a Message Queue component that references that specific queue, as shown in Figure 13. Just double-click the server component on the Component Designer, and the code for that object is opened.
Lifecycle ToolsWith Visual Studio .NET, Microsoft is focusing more broadly on the overall development life-cycle. Built with Internet scalability in mind along with an open and extensible architecture, Visual Studio .NET is the foundation for a lifecycle platform. As shown in Figure 14, Visual Studio addresses each of the phases in the development lifecycle as well as providing the key infrastructure for team management and collaboration.
To support the analysis and design phase, Visual Studio provides some significant enhancements to modeling tools. Information about these tools will be available at a later date. For the design and development phase, Visual Studio includes a full set of tools, as seen from the descriptions in this article. Both physical and logical design tools as well as a rich set of visual development tools are integrated into the IDE. As an example, a database developer can logically design his database, seamlessly convert it into a physical model, and then use the visual development tools to create stored procedures, views, user defined functions, and queries.
Visual Studio Web Test is fully integrated in the Visual Studio IDE, enabling developers to create and execute test scripts within the IDE and ensuring that their apps scale and perform as needed. Features include point and click scalability testing, the ability to validate responses, and functionality to test Web apps and perform functional Web testing.
Visual Studio also includes a low-level performance analysis tool, Visual Studio Analyzer, for identifying and fixing application bottlenecks. It has been updated for this release to include new support for capturing and raising industry standard Windows Management Instrumentation (WMI) events and the ability to modify tests while they are running.
The deployment phase for distributed applications can be difficult. As any developer who has built a distributed Web solution knows, these applications can be difficult to set up and deploy. Often server resources like message queues or performance counters need to exist on a middle-tier server before an application can run. However, included in the new tools in Visual Studio, there is a setup tool focused on distributing all tiers of a distributed application. You can build a setup that will deploy to logical machines that can in turn map to multiple physical machines. You'll also be able to build post-deployment debugging and functionality changes right into your applications.
When you build an application for Windows with the new multitier deployment projects in Visual Studio .NET, your application requires no setup. You simply point to the location of the application and run it. Additionally, applications built with Visual Studio .NET are self-repairing. If a user accidentally deletes a DLL or the application itself, it will automatically be replaced by the system. Visual Studio will include the next version of AppCenter to aid deployment to server farms and allow distributed application management with graphical tools.
ConclusionThe new features of Visual Studio .NET make it a complete development environment for building on the Microsoft .NET Framework, Microsoft's next generation Web application development platform. It provides key enabling technologies to simplify the creation, deployment, and ongoing evolution of secure, reliable, scalable, highly available Web Services while using existing developer skills. In addition, the framework provides features to help Web developers use Web Services as if they were local objects in the developers' preferred development language to simplify service and app development, and let developers focus their time and efforts on the unique services that give their company a competitive advantage. The result is faster time to market, improved developer productivity, and ultimately higher quality software.
| For related articles see:|
Rapid Application Development for the Server
Visual Studio Enables the Programmable Web
| Dave Mendlen is the product planner for Visual Basic. He was a technical product manager for Visual Studio 6 and Microsoft Office 2000 Developer. Dave is also the founder and past president of the Chicago corporate Visual Basic user group.|
From the September 2000 issue of MSDN Magazine.