XML Web Service Support in Visual Studio .NET


The XML Web service example I showed earlier demonstrated that writing XML Web services does not depend on fancy programming environments. But since developer time is the second-greatest constraint in software development (boneheaded managers who don’t know which end of a soldering iron to hold being number one), it makes sense to write our XML Web services using tools that will help us crank them out faster. Since our old friend Notepad lacks such useful features as an integrated debugger, Visual Studio .NET is usually a better choice for writing XML Web services.

When you select File/New/Project from the Visual Studio main menu, it offers you the dialog box shown in Figure 4-12. I selected Visual Basic Projects in the left pane and the ASP.NET Web Service icon in the right pane, entered a project name in the edit control, and clicked OK. Visual Studio generated a new solution containing the files shown in Figure 4-13.

An XML Web service example in Visual Studio starts here.

click to expand
Figure 4-12: Creating a new project in Visual Studio.


Figure 4-13: Visual Basic solution based on the ASP.NET Web Service template.

You’ll see a number of files that are similar to those generated in an ASP.NET application project. That’s because XML Web services run on top of ASP.NET. The Web.config and Global.asax files do exactly the same thing as they do in ASP.NET. The .vsdisco file contains information for discovery of the XML Web service by proxy generators; you will probably never touch it.

A wizard generates the basic project.

The .ASMX file is the target for client requests. Unlike this chapter’s simplest example, in which the code lived in this file, the ASMX page in this example contains a callout to code that lives elsewhere, as did the ASPX pages we saw in Chapter 3. The interesting programming takes place in the code behind file Service1.asmx.vb, in which the code that implements your XML Web service actually lives. Features such as auto-complete make the code much easier to write with Visual Studio .NET than it was with Notepad.

The .ASMX file is the target for client requests.

When you build your project, Visual Studio .NET automatically publishes it to the Web server you specify (in this case, the system default). To test the XML Web service, simply start the debugger from the Visual Studio main menu. It pops up a testing page similar to the one we saw previously in Figure 4-4, which is a very smooth way to handle things. You can set breakpoints in your XML Web service and debug anything. It’s smooth, quick, and—dare I say it—fun application development.




Introducing Microsoft. NET
Introducing Microsoft .NET (Pro-Developer)
ISBN: 0735619182
EAN: 2147483647
Year: 2003
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net