This week I had to work on an old Silverlight and WCF application. So I had to make this Silverlight 3.0 application consume a WCF service that is used to perform search in Amazon.com database. This post is about first WCF error I ran into when my silverlight application tried to call into my WCF web service. And I realized this is a very common issue lot of developers run into when developing a Silverlight application that consumes WCF service.
{System.InvalidOperationException: Could not find endpoint element with name
'BasicEndPoint' and contract 'ProductSearchService.IAmazonSearchService'
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....
The error provided me some starting point to start my diagnosis. Here are the steps that i followed and approached the solution.
When you choose Add Service Reference option in Visual Studio to add a WCF service reference to your Silverlight application, it will add a WCF client configuration file ServiceReferences.ClientConfig in your project. Open that file to check if it does have correct WCF configuration entries. Well, in my case, for some reason Visual Studio choked and added an empty ServiceReferences.ClientConfig file. So I manually added the configuration entried to create a WCF proxy.
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicEndPoint" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
<binding name="BasicHttpBinding_IAmazonSearchService"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/ProductsSearch/AmazonSearchService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IAmazonSearchService"
contract="ProductSearchService.IAmazonSearchService"
name="BasicHttpBinding_IAmazonSearchService" />
</client>
</system.serviceModel>
</configuration>
After populating configuration, I still kept getting the same when my Silverlight application tried to connect to WCF service. So I moved to next end point of this equation that was server side WCF service.
I quickly checked the service implementation code and did not find anything wrong. There was nothing to check much because my one method in service was returning statically constructed list. So at this point I did not have to worry about diagnosing any issues with Amazon.com web service itself.
Now I opened web.config file to look for configuration entries for my WCF configuration. Oh well, there was something obviously wrong. Notice binding value in endpoint configuration. It is set to wsHttpBinding
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ProductsSearch.AmazonSearchServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ProductsSearch.AmazonSearchServiceBehavior"
name="ProductsSearch.AmazonSearchService">
<endpoint address="" binding="wsHttpBinding"
contract="ProductsSearch.IAmazonSearchService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
Change the endpoint configuration to use basicHttpBinding. Recompile the service and go back to Silverlight project. Right click on the service reference and choose the option to update it. And now compile Silverlight project.
Yes, that did work. So if you are working with a Silverlight 3.0 application that is going to consume a WCF service, make sure that:
WCF Error in the ServiceModel client configuration section
InheritInChildApplications cannot be set to false error with dnn
Could not find default endpoint element that references contract error
The request does not support the API version
The tag helper 'option' must not have C# in the element's attribute declaration area
Alert and Confirm pop up using BootBox in AngularJS
AngularJS Grouped Bar Chart and Line Chart using D3
How to lock and unlock account in Asp.Net Identity provider
2023 © Byteblocks, ALL Rights Reserved. Privacy Policy | Terms of Use