Last step in this implementation is creating a client instance that can use WCF service. To implement the same, create an 'EndpointAddress' instance for the base address of the service and then create WCF client object. Following code snippet shows client program:
To show how WCF works in this implementation client service send 'request' to the running WCF service, which in turn replies with a string 'WCF IS WORKING'.
using System.ServiceModel; namespace ServiceModelSamples { class Client { static void Main() { EndpointAddress epAddress = new EndpointAddress ("http:// localhost: 8000/ServiceModelSamples/Service/PCQuestService"); PCQuestClient client = new PCQuestClient(new WSHttpBinding(), epAddress); string value1 = "request"; string result = client.fun(value1); Console.WriteLine("fun({0}) = {1}", value1, result); client.Close(); Console.WriteLine(); Console.WriteLine("Press to terminate client."); Console.ReadLine(); } } } }
We have finished creating a service and client that uses this service. To show how it works, first run the service (sandeep1.exe, in our case) and while this service is running run the client (sandeep1client.exe in our case). The client uses operations of service and produces appropriate output. In this way we were able to understand basic mechanism of WCF programming and steps required to create a simple WCF service and client application.
Get most out of your technology infrastructure investments with Dell
About CIOL | Media Kit | Site Map | Contact Us | Help | Write to us | Jobs@CyberMedia | Privacy Policy
Copyright © CyberMedia India Online Ltd. All rights reserved. Usage of content from web site is subject to Terms and Conditions.