Skip navigation

Developer .NET UPDATE, November 26, 2002

Developer .NET UPDATE—brought to you by Windows & .NET Magazine Network.
http://www.winnetmag.net


THIS ISSUE SPONSORED BY

SQL Server Magazine


SPONSOR: SQL SERVER MAGAZINE

HAPPY 10TH ANNIVERSARY SQL SERVER!
Microsoft and SQL Server Magazine want to thank you for your support over the past 10 years of Microsoft SQL Server on the Windows platform. To show our appreciation, we're running a 20-week contest that will test your SQL Server knowledge. Answer our quiz and you'll be entered in a biweekly drawing for cool prizes like Microsoft Press books and MCDBA exam vouchers. You'll also be entered to win the grand prize: a Microsoft Xbox video game console including two controllers and three Xbox games! Get all the details and enter the contest at
http://www.sqlmag.com/quiz


November 26, 2002—In this issue:

1. DEVELOPER .NET PERSPECTIVES

  • Tracing a Web Service

2. ANNOUNCEMENT

  • Give Us Your Feedback and Be Entered to Win an Xbox

3. RESOURCE

  • Visual Studio .NET 2003 Beta Now Available

4. NEW AND IMPROVED

  • Quickly Create Common Installations

5. CONTACT US
See this section for a list of ways to contact us.


1. DEVELOPER .NET PERSPECTIVES
(contributed by Bill Sheldon, [email protected])

  • TRACING A WEB SERVICE

  • Last week, I discussed how to adjust a Web application's web.config file to initiate trace logging. The Web application accesses an instance of the Trace object that's available in the context of the application to capture custom data related to the application's execution. Web services provide the same functionality. However, although a Web service is often Web based, it isn't a Web application. A Web service is a Windows application that exposes an interface. Because of this interface, a Web service reacts differently to tracing than a Web application does.

    To really understand what happens during a Web-service request, I suggest that you create a Visual C# .NET (or Visual Basic .NET) Web service in Visual Studio .NET. At this point, you have the framework for a simple Web service. Uncomment the default HelloWorld method for the sample Web service.

    Next, open the web.config file for this Web service. In the trace node, change the enabled option from "false" to "true", and run the Web service. When the browser opens, proceed to the test page for the Web service's HelloWorld method and run this method.

    The browser that opens after you run the HelloWorld method contains that method's XML output. Go to the Trace.axd page associated with the Web service. As you did last week, you can access the individual pages associated with each request you made, which are

    • the request to open the default page for the Web service
    • the request to open the page associated with the Web method (i.e., the HelloWorld method)
    • the request to run the Web method

    Examine each request in trace.axd. Because you ran a simple Web service, the first two virtual .aspx pages aren't particularly interesting. However, the trace display for the third request is quite interesting. Notice that the trace display is sparse. Although you made an HTTP GET request that included a QueryString variable, the trace display doesn't show that part of the trace information. More important, the display's Trace Information section is empty. None of the standard events associated with an .aspx request are present, nor is any timing information. Fortunately, all of the HTTP Header information is available, along with the server variables associated with the request.

    Because the trace display is so sparse, you need to add custom trace statements to enhance the display of trace information. In my November 12 commentary "Tracing Down an Error," I showed you how to use the following code to add custom trace statements:

       Trace.Write("MyCAT", "Button1 Click");
       Trace.Warn("MyCAT", "Button1 Warning");

    You need to add similar code to your Web method so that it looks like

    \[WebMethod\]
    public string HelloWorld()
    \{
       Trace.Write("MyCAT", "Button1 Click");
       //Trace.Warn("MyCAT", "Button1 Warning");
       return "Hello World";
    \}

    Notice that I commented out the line that created a warning. You have to comment out this line because the Trace object used in a Web service doesn't support this method. Although you reference the Trace object the same way in a Web service, you're actually using a different Microsoft .NET Framework class. By default, Web services interact with the Common Language Runtime (CLR) the same way that other DLLs do; as a result, you use the Trace class instead of the TraceContext class. (You can still use the TraceContext class if you want, but you must add code—a topic that I'll cover in an upcoming commentary.) The Trace class doesn't include the Warn method.

    For this week, simply place a breakpoint on the return line associated with the Web method. With tracing still enabled in the web.config file, run your application. During the call to the Web method, the application will stop at the return statement. At this point, you should have results in the Output dialog box in Visual Studio .NET. If this dialog box doesn't appear, select Other Windows, Output under the View menu. Another way to access this dialog box is to press Ctrl+Alt+O.

    In addition to seeing the Output dialog box, you should also see the trace message that you added to the Web method. Although you can see the trace message in the Visual Studio .NET display, the message won't show up in the trace display's Trace Information section when you let the application run to completion. This limitation implies that the only time you can capture custom trace information is when you're running the Web service from within Visual Studio .NET. Fortunately, that's not the case. The Trace class has a Listeners collection that you can use to specify where to send custom trace output. The Trace class is the same class that you would use for a WinForms application, so you have the option of sending the output to either a file or an event log. Next week, I'll show you how to use the Listeners collection to redirect custom trace output. In the meantime, for more information about the Trace class, I recommend this link to the product documentation.

    2. ANNOUNCEMENT
    (brought to you by Windows & .NET Magazine and its partners)

  • GIVE US YOUR FEEDBACK AND BE ENTERED TO WIN AN XBOX

  • Tell us how well your enterprise is prepared for when disaster strikes. Complete our brief survey about backup and recovery, and you could win an Xbox. Click here!

    3. RESOURCE

  • VISUAL STUDIO .NET 2003 BETA NOW AVAILABLE

  • At COMDEX Fall 2002 last week, Microsoft announced the availability of the beta version of Visual Studio .NET 2003 (code-named Everett). For more information about the Visual Studio .NET 2003 beta, see Paul Thurrott's WinInfo Daily UPDATE article "COMDEX: Microsoft Delivers Final Visual Studio .NET 2003 Beta".

    4. NEW AND IMPROVED
    (contributed by Sue Cooper, [email protected])

  • QUICKLY CREATE COMMON INSTALLATIONS

  • InstallShield Software announced InstallShield Express 4, which lets you create Windows application installations without training or scripting. A solution for common installation needs, InstallShield Express 4 lets you build straightforward installations in less than a day. New features include patch and upgrading technology, integration with Visual Studio .NET, and Web-services support. You can now perform a software inventory search and use those results to conditionally install parts of an application or to run custom actions. Priced at $349, InstallShield Express 4 runs inside the Visual Studio .NET IDE as well as in its standalone interface. Runtime support is provided for Windows XP, Windows 2000, Windows NT, and Windows 9x. Contact InstallShield at 847-466-4000, 800-809-5659, or [email protected].
    http://www.installshield.com

    5. CONTACT US
    Here's how to reach us with your comments and questions:

    This weekly email newsletter is brought to you by Windows & .NET Magazine, the leading publication for Windows professionals who want to learn more and perform better. Subscribe today.
    http://www.winnetmag.com/sub.cfm?code=wswi201x1z

    Receive the latest information about the Windows and .NET topics of your choice. Subscribe to our other FREE email newsletters.
    http://www.winnetmag.net/email

    Hide comments

    Comments

    • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

    Plain text

    • No HTML tags allowed.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Lines and paragraphs break automatically.
    Publish