Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2009 : Exposing a WCF Service (part 2) - Creating the WCF Test Client

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
7/4/2011 11:45:32 AM

4. Creating the WCF Test Client

Now that the orchestration has been configured, we can focus on creating a client that uses the certificate to encrypt the data when calling the service. To do this, create a console application in Visual Studio 2008. After creating a console application, connect to the BizTalk WCF endpoint by doing the following:

  1. Right-click the References node in Solution Explorer.

  2. Select Add Service Reference.

  3. Enter the URI to the WCF endpoint, and click GO.

  4. Change the namespace to a meaningful name.

  5. Click OK to add the reference.

For a MEX endpoint, the URI is entered as http://<servername/<vdir>/<servicename>.svc/mex.


Once the service has been added, your App.config file should look something like the following:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITwoWayAsync">
<security mode="Message">
<transport clientCredentialType="Windows"/>
<message
clientCredentialType="Certificate"
negotiateServiceCredential="true"
..........algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://bts2009rc/Math/

BTS2009_WCFDemo_Math_AddOrchestration_AddReceivePort.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ITwoWayAsync"


contract="MathService.BTS2009_WCFDemo_Math_AddOrchestration_AddReceivePort"
name="WSHttpBinding_ITwoWayAsync">
<identity>
<certificate encodedValue="AwAAAAEAAAAUAAAAV....
" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>

The Add Service Reference feature detected that a certificate is required, but there is still additional work necessary before the service can be called. The application needs to be told what certificate to use. To do this, there is additional configuration necessary. The following bold code shows the additional code added to the App.config file:

<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="MathBehavior">
<clientCredentials>
<clientCertificate
findValue="certsample"
storeLocation="LocalMachine"
x509FindType="FindBySubjectName" />
<serviceCertificate>
<authentication revocationMode="NoCheck" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_ITwoWayAsync">
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="Certificate"
negotiateServiceCredential="true"
algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>


<client>
<endpoint address="http://bts2009rc/Math/

BTS2009_WCFDemo_Math_AddOrchestration_AddReceivePort.svc"
behaviorConfiguration="MathBehavior"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_ITwoWayAsync"
contract="MathService.BTS2009_

WCFDemo_Math_AddOrchestration_AddReceivePort"
name="WSHttpBinding_ITwoWayAsync">
<identity>
<certificate
encodedValue="AwAAAAEAAAAUAAAAVYAae3Zx..." />
</identity>
</endpoint>
</client>
</system.serviceModel>

The behavior named MathBehavior tells WCF two important items:

  • The application client should use the certificate with a subject name of "certsample" that is stored LocalMachine.

  • The application client should not check the server's certificate against a CRL.

Instead of modifying the App.config file by hand, use the WCF Service Configuration Editor as part of the Windows SDK. To access this, select Tools WCF Service Configuration Editor within Visual Studio, or right-click the App.config file and select Edit WCF Configuration.


Once the application configuration has been set up, we can write the following few lines of code to call the service. The result is a working application that uses message-level certificate encryption.

static void Main(string[] args)
{
MathService.AddOrchestrationPort client =
new MathService. AddOrchestrationPort ();

MathService.Add request = new MathService.Add();
request.Number1 = 100;
request.Number2 = 200;

MathService.MathResult response = client.AddOperation(request);
Console.WriteLine(response.Result.ToString());
Console.ReadLine();
}

If we enable the diagnostics features of WCF to trace messages, the WCF Service Trace Viewer application will show that the data being sent over the wire from the BizTalk service is now encrypted. You can see this in Figure 4.

Figure 4. Service Trace Viewer showing the encrypted traffic
Other -----------------
- BizTalk 2009 : WS-AtomicTransaction Support
- SharePoint 2010 : Securing Information - Securing Lists
- Microsoft Dynamics GP 2010 : Viewing open items with the Task List
- Microsoft Dynamics GP 2010 : Managing personal reports with My Reports
- Microsoft Dynamics GP 2010 : Speeding up access to data with Quick Links & Rearranging Navigation to make it easier
- Microsoft Dynamics NAV : Installing Dynamics NAV - Preparing a Microsoft SQL Server database for Dynamics NAV installation
- Microsoft Dynamics NAV : Installing Dynamics NAV - Installing a SIDE database server
- Microsoft Dynamics NAV : Installing Dynamics NAV - Installing a Classic client
- SQL Server 2008 : Administering Database Objects - Working with Triggers
- SQL Server 2008 : Administering Database Objects - Working with Triggers
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server