Add web project to silverlight application - how to - silverlight

I have created a WCF Service application, which contains a reference to a service I created.
I want to add this service application as the web component of my SL application, but I can't seem to find the option that allows me to do this.
Can someone help me out here?
Thanks.

I think you need to create a web site, then add a reference to the WCF Service from the website. You could also just have the .svc file in the website. Then right-click on your Silverlight application project and Add Service Reference. This will generate the Reference.cs (show all project files and expand the service reference to see) that will contain all the classes that you exposed in your WCF Service through return or paramaters in your methods.

Related

Hosting legacy Silverlight application in an ASP.NET MVC3 web application

I am trying to convert an existing silverlight application to use a MVC web application versus a regular asp.net web application.
I have taken a look at fiddler and it is not able to access the domain service methods as the service does not exist (this is because these files are autogenerated once they are called with ria services). But with MVC since it looks for the controller if files don't physically exist we are getting this error.
I have tried to ignore svc files by:
routes.IgnoreRoute("{allsvc}", new { allsvc = #"..svc(/.*)?" });
and also have tried;
http://xamlcoder.com/blog/2010/01/15/upgrading-to-wcf-ria-services-asp-net-mvc-2/
With no success. Has anyone been able to successfully do this, if so, how?
Thanks in advance.

deploying services to use SQL server in silverlight

I've made a service for my silverlight 4 database (SQL) affairs (VS2010, C# ASP.NET web app), now I'm writing my SQL functions in this service, how can I use this functions? I've read some articles about deploying services but I think my case should not be much complicated, I have a big ASP.net web app with several web pages (I have a server running on winserver2008), it works great, also I have a SL app, what kind of files should I upload for using service? do I need an asmx? how can I create it? should I change anything in web.config?
what is the easiest way to use my service for communicating between SQL and SL? thanks
WCF RIA Services is the way to go. You do not want to bother with old-school ASMX web-services.
You will use an EF model and a DomainContext on the server to handle all database access via CRUD methods (Create, Read, Update & Delete).
On the client you will use the generated Domain Service client to access data.
Notes from my previous RIA post:
My suggestion is to always create RIA Service libraries instead of adding directly to a Silverlight application. Then you can link the Client-side library to any number of Silverlight applications, then link the .Web part of the RIA library to your website to provide the WCF service. Again the key is to migrate the config settings.
It will probably make a lot more sense if you create a new RIA services library project, add your EDM etc, then link the halves to a separate Silverlight app and your new ASP.net website.
Step-by-step:
Create RIA Services Library project by selecting Add New Project. Select Silverlight on the left. Select WCF RIA Services Class Library on the right. I will assume it is called the default name RIAServicesLibrary1 for this example. It will create a Silverlight client library called RIAServicesLibrary1 and a standard .Net library called RIAServicesLibrary1.Web for use by the Web server.
Add your EDMX to the RiaServices.web project. Select Add new item. Select Data on the left. Select ADO.Net Entity Data Model on the right. I will assume it is called the default Model1.edmx for this example. Connect it to your database tables etc.
Build your project so that the next step will find your data model.
Create a Domain Service referencing your EDMX models in your RiaServices.web project. Select Add new item. Select Web on the left. Select Domain Service Class on the right. I will assume it is called DomainService1.cs for this example. Choose your data items from the Add New Domain Service Class popup window by ticking the checkboxes. A set of RIA services objects and methods will be created for each item you select.
Add a reference to the client Ria services library project (RIAServicesLibrary1) to your Silverlight application.
Add a reference to the web RIA services library project (RIAServicesLibrary1.Web) to your hosting web application (e.g. you ASP.Net website).
Copy/merge the various sections in the RIAServicesLibrary1.Web/app.config file into your <webapplication>/web.config file. This will include any connection strings and the module sections.
Build the project again so that the Data Source window will see your new Domain Context data sources.
Use the RIAServicesLibrary1 client object (called DomainService1 in this example) directly from your Silverlight code like this:
DomainService1 client = new DomainService1();
or use the Data Sources window to drag/drop a new grid etc onto a page.
If the Data Sources window is not visible select the "Data" menu then the "Show Data Sources" option.
For more information try this Microsoft link: Using WCF RIA Services

Silverlight RIA Service hosting

I wonder is it possible to host RIA service as a stand alone application in IIS7? I've playing around with some RIA services and a wonder whether this scenario is possible. My goal is to detach the service from the WebSite application and host it separately.
Thanks in advance!
Definitely possible, just create another ASP.Net webforms application, add the domain service, reference your model (if its in another library), and link the Silverlight project to it. Might also be best to host your XAP in the same project as the RIA service to avoid any cross domain issues. In your real website, just copy and paste the object tag and javascript it generates and make sure its pointing to the right location on the RIA service site.

How to update WCF service reference dynamically in silverlight?

How to update WCF service reference dynamically in silverlight ?
Suppose I have created WCF service in my system and added reference to silverlight project, now when I host this on server I want that automatically it takes that system reference .
Take a look at Tim's post:
Managing service references and endpoint configurations for Silverlight applications

Where to put configuration information in Silverlight?

I am using prism and have a number of modules. In several of them I am making webservice and wcf calls. I want to be able to configure the information about these services in one place. Should I do this in a resources.resx file? I remember a settings.setting file but that was in a web application.
JD
You can put it in the app.config or you can follow this blog on passing server information to the Silverlight client.
Silverlight Bits&Pieces has this piece on Silverlight configuration options.
When you create service reference in a Silverlight Application, it should automatically generate a ServiceReferences.ClientConfig XML file and put it in your project. It will put the binding and endpoint config info in this file. If you create an instance of your service proxy object without specifying any binding/endpoint it will use the info from the file.
What you can do is the following:
In the Bootstrapper application, add a reference to that WCF
Create your own custom proxy class imlpementing an interface that dictates the methods to be called
Register this IProxy with Unity Container, then pass to each of your ViewModels an IProxy parameter. Unity will do the job by injecting the real instance of that IProxy.
This way you have based all the WCF connection in one place.
Does it help?
Regards

Resources