Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need guidance in calling WCF service from Silverlight 4

Okay guys, I call upon your combined intellects. I have a web application with a silverlight app that calls a ria service. The ria service is defined inside the web application and everything else is just dandy.

The issue is this.

It is my understanding that in order for the silverlight application to talk and know what the ria service is, you need to add a service reference for that service. The service reference defines the ria service and sets up the connection binding. One of the files it adds is the ServiceReference.ClientConfig which has the connection binding in it. During the course of this application's development, this is the way it was set up. And it worked perfectly fine locally and on the dev server.

Unfortunately there were issues when deploying to the clients in-house server. At this point I was onto other projects while my co-worker continued with the deployment. He soon became frustrated with the goofy errors that were occurring and recruited some help. This dev came in and, albeit got it working, but in order to do so he removed the service reference from the silverlight project but left the ServiceReference.ClientConfig which pointed to the location of the service in the web application(but that's it, no definition or explanation as to what the service does and I'm not sure how the silverlight app is supposed to know how to work with it..). This works perfect on my co-workers workstation and he has deployed this version to the clients server fine.

When I open the project it doesn't run at all. And the reason why is that it doesn't know what the service is that i'm using in code. Specifically, it doesn't know where this is (names changed for clarification):

Imports SilverlightApp.ServiceReference.WebApp.Service

I have cleaned the solution, completely deleted and got the latest from source control, built the web app first and made sure the asp.net dev server was running so that the address in the ServiceReference.ClientConfig resolved correctly. But, alas, it still doesn't know what Imports SilverlightApp.ServiceReference.WebApp.Service is.

So, to get it working on my workstation, I added the ServiceReference back but kept the current connection bindings so that it matched the endpoint in the web app web config. and changed the import statement to Imports SilverlightApp.ServiceReference and everything works fine.

What is the reason for this insanity?!?!

like image 384
keynone Avatar asked Nov 05 '22 22:11

keynone


1 Answers

All the things you are talking about relate to a WCF service NOT a WCF RIA Service. They work in quite different ways when consuming them in your client app.

A WCF service will require a service reference and the ServiceReference.ClientConfig.

A WCF RIA Service does not. The link to the WCF RIA service is set in the silverlight project properties in the Silverlight tab at the bottom. When you build it will generate client side context code in the Generated_Code folder. Show all files and you will see it.

Hope that helps?

Kevin

like image 104
Kevin Westwood Avatar answered Nov 09 '22 14:11

Kevin Westwood