Debugging a Web Service at the Server

To debug a Web Service that resides on a machine that has Visual Studio .NET installed, you have two options—start the application or, if it has been started already, attach to the process executing the Web Service.

To start the Web Service from within Visual Studio .NET, you first have to make sure that the aspnet_wp.exe process has not been loaded. The surest way to do this is to open a command prompt and type iisreset. This stops and restarts IIS and any related applications. Then, in the Solution Explorer pane, right-click the asmx file you want to debug and select the Set as Start Page item from the pop-up menu. Then, go to the Debug menu and select Start. If the ASP .NET-generated Web pages allow you to interact with the Web method you need to debug, you should be set. If a client application is needed because the method takes a complex type or an array as an argument, you should be able to still hit the breakpoint.

One drawback to the previous method is that running iisreset all the time can be time consuming. Cycling IIS off and back on again can often take a minute or longer. Because of this, it might be more convenient to debug the already running process. ASP .NET Web Services run in the aspnet_wp.exe process. To debug a Web Service that has already been loaded into memory, you need to attach to aspnet_wp.exe. Do the following:

1.
Open the project you want to debug.

2.
Set your breakpoints.

3.
Go to the Debug menu and select the Processes menu item.

4.
In the Processes dialog (see Figure 5.7), make sure that the Show System Processes check box is checked. aspnet_wp.exe is a system process.

Figure 5.7. The Processes dialog.


5.
Select the aspnet_wp.exe process and click the Attach button.

6.
In the Attach to Process dialog (see Figure 5.8), make sure that the Common Language Runtime item is checked.

Figure 5.8. The Attach to Process dialog.


7.
Click OK.

8.
On the Processes dialog, click the Close button.

9.
Wait for the IDE to stop on your breakpoint. This last step assumes that you have a client application that you can invoke that will hit the Web Service. The client application does not need to be loaded within Visual Studio.

These techniques will help you find problems when the development tools and the Web Server are on the same machine. Now, what do you do when the Web Service is having problems and it is on a live server?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.205.27