RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


The Baker's Dozen: A 13-Step Crash Course for Learning Windows Communication Foundation (WCF) : Page 6

WCF is meant to make things easier for developers, but as with any new technology, getting started can be difficult. Follow these thirteen steps to rev up your WCF knowledge quickly.

Step 11: WCF Services for Non-.NET Clients, (Part 2 of 3)—Registering the Service
Before you consume the service with a non-.NET client, you need to register the service with IIS and ASP.NET 2.0. The .NET 3.0 Framework contains a utility called ServiceModelReg.exe that you can use, as follows:

   -- Location for ServiceModelReg.EXE
   -- "\Windows\Microsoft.NET\Framework\v3.0\
         Windows Communication Foundation"
   -- Syntax:
   ServiceModelReg.EXE -s:W3SVC/1/ROOT/TestWCFService
ServiceModelReg registers the service and creates the necessary script maps.

Step 12: WCF Services for Non-.NET Clients, (Part 3 of 3) (VFP)
Finally, you can also access the WCF XML Web service using a non-.NET client. Because I was a Visual FoxPro developer in a past life, I'll use VFP to consume the service. Here's a brief code sample:

   -- VFP code to consume a WCF service, 
   -- in the same way as an ASMX 
   LOCAL loBasicHttpBinding_IMyService 
     AS "XML Web Service"
   LOCAL loException, lcErrorMsg, loWSHandler
   loWSHand = NEWOBJECT("WSHandler",HOME() + 
   loBasicHttpBinding = loWSHand.SetupClient(
      "DemoService", "BasicHttpBinding_IMyService")
If you ever consumed ASMX services in VFP, you'll notice that the code is basically the same!

Step 13: WCF Security Options
With WCF, you are sending SOAP messages over all the supported protocols (TCP, HTTP, etc.) Therefore, you need to implement security (for authentication, encryption, etc.). WCF security is a complete topic in itself (see the Recommended Reading section for more on this topic), which is beyond the scope of this article.

Table 2 lists the main security modes for all the WCF communication bindings.

Table 2: WCF Security Modes








You can specify security settings in the configuration files that you built in previous steps. For example, the following requires that messages must be passed with user credentials:

     <binding name="wsHttp">
       <security mode="Message">
         <message clientCredentialType=
            "UserName" />
You can find the entire source code for this article on my Web site. For additional information, check out my blog.

Kevin S. Goff is the founder and principal consultant of Common Ground Solutions, a consulting group that provides custom web and desktop software solutions in .NET, Visual FoxPro, SQL Server, and Crystal Reports. Kevin has been building software applications for 17 years. He has received several awards from the U.S. Department of Agriculture for systems automation. He has also received special citations from Fortune 500 companies for solutions that yielded six-figure returns on investment. He has worked in such industries as insurance, accounting, public health, real estate, publishing, advertising, manufacturing, finance, consumer packaged goods, and trade promotion. In addition, Kevin provides many forms of custom training.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date