WCF Client Differences
-
Hi folks, I've being starting out on WCF, I made a service and uploaded to my shared hosting.(after a bit of fiddling with configs, switching off security) I then navigate to the service.svc and it shows the metadata page. I run svcutil [address] and get a proxy class which I can consume through my console program. It all works fine I can add two numbers together! However... I try it in Silverlight this time adding a service reference, now when I instatiate the reference I get a KeyNotFoundException. What are the differences I need to be aware of when use a WCF service from silverlight?
-
Hi folks, I've being starting out on WCF, I made a service and uploaded to my shared hosting.(after a bit of fiddling with configs, switching off security) I then navigate to the service.svc and it shows the metadata page. I run svcutil [address] and get a proxy class which I can consume through my console program. It all works fine I can add two numbers together! However... I try it in Silverlight this time adding a service reference, now when I instatiate the reference I get a KeyNotFoundException. What are the differences I need to be aware of when use a WCF service from silverlight?
Hi Colin, This problem was driving me mad on Friday so I thought I would let you know the answer :) What you need to do is open the ServiceReferences.ClientConfig file in your Silverlight application that contains the client Service Reference. When I did this, I noticed it only contained an empty tag . What I then did was open the Web.config file in my host web application project (that contains the Web Service to be consumed). Locate the entry at the bottom for the service you are trying to expose to the Silverlight app. Change the binding attribute to "basicHttpBinding". Save the file. Switch back to the ServiceReferences.ClientConfig file we opened earlier, in Solution Explorer, under Service References folder right click the service reference and select "Update Service Refeernce". You will notice that the config file is now populated correctly and you should be able to use the service now. The default binding appears to be wsHttpBinding which for some reason does not generate any code in the ServiceReferences.ClientConfig file. See if that works :doh: Peter
-
Hi Colin, This problem was driving me mad on Friday so I thought I would let you know the answer :) What you need to do is open the ServiceReferences.ClientConfig file in your Silverlight application that contains the client Service Reference. When I did this, I noticed it only contained an empty tag . What I then did was open the Web.config file in my host web application project (that contains the Web Service to be consumed). Locate the entry at the bottom for the service you are trying to expose to the Silverlight app. Change the binding attribute to "basicHttpBinding". Save the file. Switch back to the ServiceReferences.ClientConfig file we opened earlier, in Solution Explorer, under Service References folder right click the service reference and select "Update Service Refeernce". You will notice that the config file is now populated correctly and you should be able to use the service now. The default binding appears to be wsHttpBinding which for some reason does not generate any code in the ServiceReferences.ClientConfig file. See if that works :doh: Peter
Yeah, that was problem number one, change to basicHttpBinding (case sensitive, I think) Unfortunately what I was trying to do in the webservice didn't work as it needed to be called from the main thread synchronously, and Silverlight only allows asynch. I was trying to save an image by posting back the XAML and using the webservice to create an image, but couldn't find a way to get it to work, ah well, nevermind, back to a desktop program.