I have a WCF project (:53763/WCFTestService.svc) and a web application(:50238/CSharp/test.aspx) in C#. I am trying to call the WCF project method in my web application. I have added the WCF project as a service reference in web application.
in test.aspx.cs file I have a method as follows
[WebMethod()]
public static string GetWCF()
{
WCFTestServiceClient client = new WCFTestServiceClient();
string result = client.XMLData("1122");
return result;
}
When I run this getting error :
Could not find default endpoint element that references contract 'TestWCFServiceReference.IWCFTestService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element
.
When I add the WCF project as a service reference in my web application, the web.config file in the web application is not updated automatically. (No code is added by default at the time of adding reference). Do I need to add anything in the web.config file for making it working?
web.config of WCF project is:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WCFTestService.RestService" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="WCFTestService.IRestService" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<!--<behavior>
--><!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --><!--
<serviceMetadata httpGetEnabled="true"/>
--><!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --><!--
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>-->
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>