Implementing WCF Service Virtualization
Implementing WCF Service Virtualization
Description:
This document can be used in conjunction with the .NET Routing Service documentation to assist users in setting up their WCF service for Virtualization. We will be focusing on the second method of configuration using a Virtualize Proxy and specifically reviewing the requirements for configuring the AUT to point to the .NET Routing Service.
AUT <-> .NET Routing Service <-> Virtualize Proxy <-> .NET Routing Service <-> Real WCF Service
Solution:
Aside from configuring the AUT to point to the “AutToVirtualize” address, the user will need to apply the correct Service bindings in their proxy configuration file as described in Microsoft's documentation. The most efficient way to configure your proxy configuration file is to extract the bindings from your current working client configuration file or use the Service Model Metadata Utility Tool (svcutil) to generate a new one.
For example, a user could do this from the command line with the following syntax:Svcutil.exe http://[REAL-SERVICE-URL?WSDL]
This will generate a configuration file and a code file that contains the client class. We will only need the configuration file for our scenario. Once a configuration file is acquired, we can copy the bindings to our proxy "RoutingService.exe.config" file and move on to configuring our AUT to point to the “AutToVirtualize” address.
Example:
1. Open Command Prompt and run the following command:
Note: You may need to open the command prompt in Administrator mode to generate the configuration files successfully.
The output.config file will be generated in the same directory where SvcUtil.exe is located.
2. Open the output.config file. Copy the bindings that are associated with the endpoint you wish to Virtualize. The binding attributes generated will vary depending on your service and the svcutil you used to create your output.config file.
Note: The binding highlighted above describes the transport, security, and message encoding for the web service’s endpoint. The SOAP Client needs to know the endpoint’s binding to communicate with the endpoint successfully. In this case, there is no security enabled for my endpoint, therefore, the security mode is set to “None”. The SOAP Client can determine the endpoint’s binding automatically from a WSDL document or in this case, from a .NET WCF client configuration file.
3. Paste these bindings in your Proxy configuration file, RoutingService.exe.config, accordingly. This will allow for the proxy to communicate with the Service.
4. As documentation suggests, you will also need to configure your AUT to point to the “AutToVirtualize” address (Routing Service). In your client configuration file, locate the Service endpoint you wish to Virtualize. For my example, I used the same output.config file generated from earlier as my new client configuration file. You may also choose to modify your client config file instead (the config file that is currently used to communicate with your service directly).
5. Replace the real endpoint with the routing address endpoint. I used the default routing address shown below: net.tcp://localhost:8001/router/AutToVirtualize
6. You may create a Provisioning Action to confirm that your client config and proxy config files were configured correctly.