Debugging Web ServicesI tried debugging some Web Methods (WM) in a Web Service (WS) using Microsoft Visual Studio 2005 and noted the following things.
When your WM having simple parameters (Integers, Strings) if you run your project internet explorer will open up with text boxes to enter your parameters. After entering there will be a button named Invoke to invoke the WM. That will invoke your WM with the parameters you have provided.
But the thing is if your WM is accepting complex types as parameters (Objects, Datasets, Tables {Even though it is not recomended to supply complex objects like datasets to WMs there may be scenarios that it will save lot of development time of yours.}) then you will not see either textboxes or an Invoke button. As a result you will not be able to debug the WM.
Do not worry because I found the way to debug.
First you have to publish your WS to Internet Information Services (IIS). To make things simple for you Visual Studio will do the publishing for you. Before that make sure that your IIS is running by typing
http://localhost/ in your web browser.
Then right click on your WS project in the Solution Explorer and click on Publish.... This will open up the Publish Web form to you. In that enter the target location as shown. Remember to change the IP address used to your IP address or you can put your machine name or localhost instead using IP address.
Click on Publish. This will create a virtual folder inside IIS and your compiled WS will be copied in to the virtual folder. Now your WS is hosted. In some cases you may have to give permission to the WS. If you needs then open IIS Manager by typing 'InetMgr' in the run windows. Browse to your newly created virtual folder, right click on the folder and click on properties.
In WebService properties window check if 'Script Source Access' check box is checked, if not then check that and click Apply and click Ok.
Now we have published the WS, we'll setup debugging.
Right click the WS in the Solution Explorer and click Properties. In the project properties page click on the Web tab. In that as the default, WS will be set to run on a virtual server comming with Visual Studio. We have to change this because we are not been able to debug on virtual server. To do this select the radio button 'Use IIS Web Server' and set the project URL to the same location you entered in the Publish Web screen.
Now close the WS properties screen and press F5 or Debug -> Start Debugging. This will start the
Internet explorer and will load your web service. Keep that as it is and put some breakpoints in the
WS code.
Then use the web service. I did use the
WS from a
PDA application. When ever the call is made the web service will break at the breakpoints you have put then you will be able to debug as usual (using the windows as such Immediate, Watch, etc)
ConclusionIn Visual Studio normally it will start the
WS in its virtual server. We have to point that to
IIS to make it
debuggable. That can be done by setting Web properties in the
WS properties.