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() +
"FFC\_ws3client.vcx")
loBasicHttpBinding = loWSHand.SetupClient(
"http://localhost/WCFDemo/Service.svc?wsdl",
"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
Contract |
None |
Transport |
Message |
Both |
TransportWithMessageCredential |
TransportCredentialOnly |
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:
<wsHttpBinding>
<binding name="wsHttp">
<security mode="Message">
<message clientCredentialType=
"UserName" />
</security>
</binding>
</wsHttpBinding>
You can find the entire source code for this article on
my Web site. For additional information, check out
my blog.