Adding WCF reference to a C# web application -
i have wcf project (:53763/wcftestservice.svc) , web application(:50238/csharp/test.aspx) in c#. trying call wcf project method in web application. have added wcf project service reference in web application.
in test.aspx.cs file have method follows
[webmethod()] public static string getwcf() { wcftestserviceclient client = new wcftestserviceclient(); string result = client.xmldata("1122"); return result; } when run getting error :
could not find default endpoint element references contract 'testwcfservicereference.iwcftestservice' in servicemodel client configuration section. might because no configuration file found application, or because no endpoint element matching contract found in client element
.
when add wcf project service reference in web application, web.config file in web application not updated automatically. (no code added default @ time of adding reference). need add in web.config file making 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> --><!-- avoid disclosing metadata information, set value below false , remove metadata endpoint above before deployment --><!-- <servicemetadata httpgetenabled="true"/> --><!-- receive exception details in faults debugging purposes, set value below true. set false before deployment 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>
it sounds there's error you're going need resolve when reference wcf project. on information tab (not warning/errors) on visual studio when add reference , you'll see errors. i'm guessing it'll have newtonsoft.json - there many posts about, such error adding service reference: type recursive collection data contract not supported
Comments
Post a Comment