SIlverlight and WCF RIA - silverlight

I have an application where I present the data to the users by using Silverlight 4 and WCF RIA Services. In this application I have also a module (console app) which is responsible to store in the DB some flat files (xml files).
My question is: According to the best practices which one of these two options is the best?
Reuse the WCF RIA Services also for the Console App to store the flat files in DB.
Create others WCF Services specific for the Console App to store the flat files in DB (with ServiceContract).
Any idea? Or other options?
THANKS!

All I can say is it is always a best practice to reuse any code that can be reused. I don't see why you would want to create a whole new service layer for another application? Being reusable (over multiple applications/platforms) is the point of web services.

Related

Managing multiple WCF services in one project

Currently I am working on an ERP Project, Using Entity FrameWork and WCF at server side and WPF at client side. Since it is a big project , we have a lot of entities.What we did so far is, Created Service contracts for each Entities and exposed with multiple endpoints.The Problem is we had to add Service Reference for each Service and we are feeling difficult to manage these web services.
1.Is this a proper way ?
if yes,
2.Is there any way to allocate these web services (in classes or folders)..?
Thanks in advance.
You don't want to keep generating the proxy classes in the client.
Just move the POCO classes and contracts to single assembly which you can reference in the server and client. Then create the necessary channels in the client with ChannelFactory.
ChannelFactory(TChannel)
If you are dealing with many services you can create routing service which will behave like facade. Once you have routing service defined then all requests are going to be sent towards routing service and then, based on some criteria, provided to specific service. You are dealing with only one service so if any change in sub-services occures, for instance endpoint's address is altered, then such a change needs to be reflected only in routing service.
Finally i got how to deal with multiple Services
i am considering to use svcutil.exe in order to create proxy classes.
so that we can arrange those classes in folders, and also we can
get more control over proxies

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 access PostgreSQL with Silverlight

I create hangman game with silverlight ironpython and I use data in postgresql for random word but I don't know to access data in postgresql in silverlight.
how can or should it be done?
Thanks!!
From Silverlight you cannot access a database directly (remember it's a web technology that actually runs locally on the client and the client cannot access your database directly over the internet).
To communicate with the server from Silverlight, you must create a separated WebService either with SOAP, WCF or RIA Services for example.
That Webservice will expose your data on the web. Call the WebService method to get your data from your Silverlight program.
This WebService layer will be your middle tiers that actually makes the bridge between your postgresql database and your Silverlight application.

How does a Silverlight client access Azure stored data?

I am thinking of developing a Silverlight application and want to make use of Windows Azure for the data storage (as well as scalability etc). But I am not sure how to get data to and from Azure using Silverlight. What technologies should I be investigating? What is the recommended approach for this scenario?
Should I be looking at using the Entity Framework from Silverlight? But then how would the EF get data from Azure and even more importantly get changes saved back again? Or do I need to go for something more custom?
Check out .NET RIA Services:
Build a Simple Application with .Net RIA Services (Silverlight 3)
Creating applications with .NET RIA Service Part 1 - Introduction
Basically, you're going to use Azure Table Storage to store the data and Blob storage if you have really large (> 64K) data elements. Table Storage and Blob Storage have REST interfaces, and you should look at the StorageClient sample in the Azure SDK as a way to CRUD the data. You can use these interfaces (Table and Blob) exclusively if you don't plan on exposing a public API.
However, lets say you want to be the next Twitter, and you want to expose a REST interface to the public... Even though Azure Table Storage has it's own REST interface, you create a small WCF service in a web role that exposes some specific WCF methods in a more compelling way. You can also publish your data in JSON, which could be more useful to non-Windows data consumers.
Here's a page that I found really helpful:
Azure Application Part 3: Expose (REST) Web Service And Consume in Silverlight.
And if you'd like to see my example, http://www.netalerts.mobi/traffic exposes data that's stored in Azure Table Storage. http://www.netalerts.mobi/traffic/api.aspx describes the REST apis that are public. In my implementation I call Table Storage via REST, manipulate the data, and then serve it up again in the public api.

Resources