Use Case
| • | You want to be able to communicate with the automation service from within your application. |
Remarks
The method you use to communicate with the automation service will depend largely on the language your application is written in. Obviously, we can't cover every possible language and IDE in this guide, so we will focus on the technologies and products used to develop ClearCanvas, namely C#, .NET and Visual Studio 2005.
Option 1: Add a Web Reference
This method will essentially generate a SOAP Web Service proxy. If you are more familiar with ASP .NET and/or your application is actually a web application (e.g. you want to use the automation service from within a web page), then this may be your preferred option. Also, this option does not require your application to be dependent on WCF and .NET Framework 3.0, which may or may not be important to you. Here are the steps you will need to take:
If successful, the Add Web Reference window will show the methods the service provides (e.g. ActivateViewer as shown above). Enter a value for Web reference name, like ViewerAutomationServiceClient, and click Add Reference. A proxy class named ViewerAutomationServiceClient has now been generated and will appear under Web References. |
Option 2: Add a WCF Service Reference
Note: in order to be able to use this functionality in Visual Studio 2005, you must have the Extensions for .NET Framework 3.0 (WCF & WPF) installed. Unfortunately, in order to encourage developers to switch to Visual Studio 2008, this package is no longer available from Microsoft. However, as of the time this section was written, it was still available from ZDNet. The steps that must be taken are very similar to adding a Web Reference, the main difference being that the proxy class generated uses WCF, and hence .NET Framework 3.0. The main benefit to this is that you are not limited to using the HTTP (SOAP) Web Service provided by the viewer—you can use the local Named Pipes service as well. There are a few benefits to using Named Pipes over HTTP:
Now, let's add the service reference:
|
Option 3: Use ClearCanvas Assemblies Directly
The first two options keep your code completely independent of the CC Framework, which has it's benefits in terms of minimizing dependencies if all you are doing with CC is automating the viewer. However, if you don't object to the dependencies, or your code is already dependent on some parts of the CC Framework, then this may be your best option. The CC Framework provides some extra classes that make automating the viewer even easier. More on this in the later sections. For now, do the following:
|
By now, you should have what you need to automate the viewer. You can start the viewer process from within your application, and you have a service proxy class to communicate with it. From this point on, the samples will use the WCF proxy class from Option 3, since there is really not much difference between any of them from a coding perspective.
Examples in Code Base
| • | ClearCanvas.ImageViewer.DesktopServices.Automation.TestClient.csproj (C# project) can be conditionally compiled (e.g. Debug or Debug ASP) to use either a WCF or SOAP proxy. |