I have a WCF service that is hosted in IIS. I also have a WCF client (console application). I used svcutil to create a proxy class and configuration file, and then added them to my client project. It is built correctly. But when I tried to run the program, it throws an exception below
Could not find the default endpoint element that references the IService contract in the ServiceModel client configuration section. Perhaps this is due to the fact that the configuration file was not found for your application, or because the leaf element corresponding to this contract was not found in the client element.
// Code of my client program
namespace MyFirstWCFClient { class Program { static void Main(string[] args) { ServiceClient objClient = new ServiceClient(); Console.WriteLine("Client calling the service...."); string strName=Console.ReadLine(); Console.WriteLine(objClient.HelloWorld("Shyju")); Console.Read(); } } }
My client's output.config file
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Message"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://localhost/IISHostedserviceTest/Service.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" contract="IService" name="WSHttpBinding_IService"> <identity> <dns value="localhost" /> </identity> </endpoint> </client> </system.serviceModel> </configuration>
and in web.config my service has the following configuration
<system.serviceModel> <services> <service name="Service" behaviorConfiguration="ServiceBehavior"> <endpoint address="http://localhost/IISHostedserviceTest/Service.svc" binding="wsHttpBinding" contract="IService"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> <behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>
I used this ( http://www.wcftutorial.net/WCF-IIS-Hosting.aspx ) to try using WCF.
Can someone help me solve this problem?
Shyju source share