(c) 2002 Visual Studio Magazine 
Fawcette Technical Publications

Issue: March 2002
Section: Web Services
Author: Josh Lane
Filename: vs0203ws

Installation steps

1. Be sure that Message Queuing is installed on your machine, and that both the Message Queuing and Message Queuing Triggers services are running.  Also, be sure that "World Wide Web Publishing" and "Distributed Transaction Coordinator" services are running, too.

2. Using SQL Enterprise Manager, create a new database called "HelpDeskRequests".  Then, use a SQL execution tool like SQL Query Analyzer to execute the commands contained in the "HelpDeskRequests.sql" file against the HelpDeskRequests database.

3. Note that the hard-coded database connection string in the sample code uses "sa" as login name and "" (empty string) as password to connect to the database.  If you want to use a different login and password, change the connection string on line 17 of VSM_HelpDesk\RequestWriter.vb to reflect your desired login and password.

4. Using the Internet Services Manager MMC, create a new Virtual Directory called "HelpDeskRequestProcessor".

5. Unzip the project files, and copy the "HelpDeskRequestProcessor" project files into the directory created for the "HelpDeskRequestProcessor" virtual directory from the last step.  The other project files can go in another directory.  Open the VSM_HelpDesk.sln file.  If prompted for a program to use for opening the file, select Visual Studio.NET (devenv.exe).  Once open, you may need to manually point the solution to your "HelpDeskRequestProcessor" virtual directory, since my file system is probably different than yours.  :-)  If you cannot reconfigure the path, you may need to build the web service separately from the other projects.  Either way, you now need to build the entire solution (all 4 projects).

6. Install VSM_CommonTypes.dll into your machine's Global Assembly Cache (GAC), found at "<OS drive>:\Windows\assembly" or "<OS drive>:\WINNT\assembly".  This can be done by either drag-and-drop from the VSM_CommonTypes\bin directory to the assembly directory, or by using "GacUtil /i VSM_CommonTypes.dll" (assuming the \Microsoft.NET\FrameworkSDK\Bin directory is part of your system path).

7. Install the VSM_HelpDesk components into a COM+ application by using RegSvcs.exe.  Make sure the Microsoft.NET\FrameworkSDK\Bin directory is in your path, and use "regsvcs /c VSM_HelpDesk.dll".

8. In the Computer Management console, open the Message Queuing\Private Queues node.  Right-click the Private Queue node and select "New->Private Queue".  Enter "HelpDeskRequests" for the name, and select the "Transactional" checkbox.

9. Open the Message Queuing\Message Queuing Triggers node, right-click on Rules node and select "New->Rule".  Enter "ProcessHelpDeskRequests" as the name and click Next.  No condition is needed, so click Next again.  Select "Invoke COM Component", enter "VSM_HelpDesk.RequestHandler" for ProgID, and "ProcessMessage" as the Method name.  Click the "Parameters" button, select "Queue path name (as string)" for the Parameter, and then click "Add", then "Ok".  Click "Ok" once more.

10. Open the Message Queuing\Message Queuing Triggers node, right-click on Triggers node and select "New->Trigger".  Enter "HelpDeskRequestTrigger" as the name, select "User queue" and enter ".\Private$\HelpDeskRequests" as the queue name.  Click next, and add the rule from the last step to the trigger.  Then click "Ok" to exit.

11. Some of the names from the last 3 steps are hard-coded in the sample code, so use them exactly as they appear here.

12. You can run the entire sample by running the VSM_SampleClient.exe application.

13. To debug the HelpDeskRequestProcessor project, set it as the startup project in Visual Studio.NET and select "Debug->Processes", select "inetinfo.exe" as the process and click "Attach".  Set a breakpoint in the code, run the sample client app, and your breakpoint should be hit when processing moves into the web service.

14. To debug the VSM_HelpDesk project, set it as the startup project, attach it to "mqtgsvc.exe" (this is the MSMQ Trigger service), and when the web service submits a new message to the queue, the trigger service will call the RequestHandler component.  If you set a breakpoint there (before you run the sample client app), you can step through the code.

15. One additional note... if you modify any code and rebuild it in between debugging sessions, you'll need to do a few things to get the code to run correctly again.  First, if you are rebuilding VSM_HelpDesk.dll or VSM_CommonTypes.dll, manually delete the "VSM_HelpDesk" COM+ application (use the "Component Services" MMC).  Then, purge any messages in the message queue that may remain from previous, aborted transactions.  Then, shutdown and restart the Message Queue Triggers service... it will keep the VSM_HelpDesk.dll loaded in memory and not allow you to rebuild it.  Now, rebuild the DLLS as needed.  Then, if you deleted the COM+ application, re-register it using step 6 from above.  If you rebuilt VSM_CommonTypes.dll, follow step 5 to copy the new version into the GAC.  You can remove older versions from the GAC if they are no longer used.

If you have any significant problems, feel free to email me at jplane@charter.net.  I can't promise to solve every problem, but I'll do my best.  :-)
