I created a “Ajax enabled WCF service”. I can consume the service from javascript code and the WebService works as intended. But, I want to write ATP’s around it. So, I am adding the webservice as a “Service Reference” into my ATP Project. Then I am using calling the webservice as usual. It all compiles fine. But when I run the ATP, it throws me back this error
“System.InvalidOperationException : Could not find endpoint element with name ‘ServiceReference1.IWCFService’ and contract ‘ServiceReference1.IWCFService’ 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 name could be found in the client element.”
This is what I have in my App.config file of the ATP.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWCFService" 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>
<client>
<endpoint address="http://yashworkspace/BSS/WS/ServiceReference1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCFService"
contract="ServiceReference1.IWCFService" name="BasicHttpBinding_IWCFService" />
</client>
<services>
<service name="ServiceReference1.WCFService">
<endpoint address="http://yashworkspace/BSS/WS/ServiceReference1.svc" behaviorConfiguration="org.proj.WebServices.WCFServiceAspNetAjaxBehavior"
binding="webHttpBinding" contract="org.proj.WebServices.IWCFService" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="org.proj.WebServices.WCFServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Please let me know what could have gone wrong??
I have a normal WCF Service and that is working totally fine.
Please help.
regards
Yash
The above answer from Drew Marsh is partially right. But the main issue is solved as follows.
Additionally,
Here the issue is, when u expose the WCF as a ajax enabled WCF service, it communicates using JSON. When you are calling the same service from a C# code, it called it using a SOAP request. So you need to configure your service such that it accepts both JSON and SOAP requests. So, in the services section, you need to configure it as follows
In the behaviors section, you need to configure your endpoint behaviors as follows..