WCF A2Z Hands On Lab (HOL) - Tutorial/Lab # 01 (a) - Client Application
Step 5. Create New Console Project for creating Client Application the Service - Start running the Service when you generate the Proxy of the Service

5.1- Added Service Reference of the created Service

5.2- Created Proxy Class of the created Service - In service explorer click on show all files then a set of files will be showing which are auto generated, the proxy class file is here Reference.cs

5.3 This also generates the service binding details in App.config file

5.3 Auto generated Binding Details of the service in App.config file

<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyFirstService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
5.3 Auto generated End Point of the service in App.config file
<client>
<endpoint address="http://abu:8080/WCFKolkataNET/HOL/MyService" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMyFirstService" contract="MyFirstServiceClient.IMyFirstService"
name="BasicHttpBinding_IMyFirstService" />
</client>
5.4 Code in Prorgarm.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace KolkataNETWCFHelloWorld
{
class Program
{
static void Main(string[] args)
{
EndpointAddress endPointAddr = new EndpointAddress("http://abu:8080/WCFKolkataNET/HOL/MyService");
MyFirstServiceClient clientProxy = new MyFirstServiceClient(new BasicHttpBinding(), endPointAddr);
string strResponse = clientProxy.MyFirstMethod();
Console.WriteLine(string.Format("Response from MyFirstService: {0}", strResponse));
Console.WriteLine();
Console.ReadLine();
}
}
}
Run the Client Application
