Click here to Skip to main content
15,922,512 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi
I am developing a silverlight web application which uses WCF service methods to interact with database..
I got System.ServiceModel.CommunicationException. I dont know where it went wrong. Here is the code section Im using...

In MainPage.xaml.cs:

private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            c.GetNameCompleted += new  EventHandler<GetNameCompletedEventArgs>(c_GetNameCompleted);
            c.GetNameAsync();
        }

        void c_GetNameCompleted(object sender, GetNameCompletedEventArgs e)
        {
            txtCustName.Text = (string)e.Result;
        }

Thanks in Advance,
Naresh.
Posted

1 solution

The issue is when you add a WCF service in your asp.net web project it by default adds the wsHttpBinding as a default configuration. Now looks like the Silverlight does not have WSHttpBinding implemented yet so I was using BasicHttpBinding on the client side. WSHttpBinding uses SOAP 1.2 while BasicHttpBinding uses SOAP 1.1 & hence the protocol exception. The solution as you might guess is to change your web.config to have binding="basicHttoBinding" -> refresh the service ref in SL project.
 
Share this answer
 
Comments
S.M.Naresh 4-Mar-11 0:45am    
Hi Koushik
Thanks for your help.Eventhough the binding is BasicHttpBinding,I got the same error. Let me give detail outlook of my scenario.
Im developing a SL Web app.I created a Wcf service application where the wcf methods interact with DB.I used Svcutil.exe to create a client and output.config file which I included in Silverlight project.Now I call the method GetName() of the CustomerService (tool generated wcf client)and now I got InvalidOperationException giving detail "Could not find default endpoint element that reference Contract ICustomerService... ".I have tried various approaches and modified config files but could not find any solution...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900