Silverlight RIA Service hosting - silverlight

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.

Related

Send simple data from wp7 to winforms application

I want to send simple data (geolocation data to be precise) from Windows Phone 7 application to a windows forms application and use it, as I'm a total beginner in this field I don't know which tools to use.
I searched about wcf services and tested this method but there's some issues: the data is sent from the phone application but isn't sent to the winforms application (guess something is missing)
If your know how to do this in a quick way, or have good tutorials I'll be thankful.
EDIT
I found this tutorial, it show how to connect directly wp7 application and desktop application without using sockets neither wcf service, I'm wondering if it is really works if the application isn't in localhost.
the like for the tutorial: wp7 tutorial
I had a similar problem and so I created a REST/JSON WCF service hosted in IIS with AppHarbor to provide the data. There's hundreds of ways to do it (Ruby/Heroku, etc..), but that particular one fits well within the Microsoft stack. I also needed to share route data and I used the WCF service to wrap the BingMaps services so that route computations are cached and shared. Considering that I had already created a local model, moving it out of my phone project into a service took less than a few hours (including the usual config hiccups, and forgetting to add the appharbor user to my bitbucket repo).
Consuming the service from WinForms (or any client) shouldn't be an issue as the service knows nothing about the client implementation.
Here's a tutorial from code project. REST WCF Service with JSON
I think you would need to implement some sort of server side solution which you could upload to on your Windows Phone and download from on your Windows Form application. This could be achieved using a WCF service which was connected to a server side database.
Another option would be to use sockets and communicate directly with your WinForms application. Check this tutorial on how to use basic sockets on WP7.

Silverlight + Custom RIA Services

Good day!
I'm developing a Silverlight Solution with a lot of projects that uses RIA Services. Each silverlight project have Silverlight + Own Ria Services project. I want to make only one RIA services project and all silverlight project consume it.
The problem is when I set the "WCF RIA Services Link" to the new RIA Services, the Silverlight project works ok, my ViewModel class works ok, but, when I'm running, the application give me the error:
"Load operation failed for query 'GetList'. The remote server returned an error: NotFound."
When I test on the browse http://localhost/Project-Web-Services-Patrimonio-ClassService.svc runs ok.
How can i do to make it ok?
[]'s
Tiago Schäffer
I think you will find you are missing the RIA services web library config settings in your web app.
Taken from my answer here. Key notes in bold.
Use the RIA services project option to create your service library. That creates 2 projects that are bound together (for code gen of the proxy objects). Both are effectively just libs (1 Silverlight and 1 .Net)
Link any RIA services client library to you Silverlight app. Then link the .web RIA project to your hosting web app (for the standard RIA use). You can also add the .web library to your Wcf service as a .Net lib (not consume it as a service).
If you did not create your main Silverlight project as a RIA services project you will need to move the settings across from the app.config file to your web.config file. If you already have the service support settings you only need to copy the db connection string across. The db connection string only should be needed for you Wcf project.
You should then be able to either use the server-side RIA calls (don't forget to add your own submitchanges calls as RIA does that behind the scenes once per batch of updates), or just use the data layer (EF etc) directly.

Call a WCF from only my silverlight application

I have a WCF.
I have a silverlight application.
I do not want anyone to be able to call the WCF except the Silverlight application.
I do not want to install any certificates on the client.
I do not want to hit any databases.
What would typically be the best way to do something like this?
You can address this using a cross domain policy file. Silverlight cannot connect to WCF services hosted on secondary domains without the implementation of this policy file.
Here are two links to get you in the right direction
http://msdn.microsoft.com/en-us/library/cc197955%28v=vs.95%29.aspx
Tim Heuer has a good writeup on the implementation of this file as well.
http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx
To prevent a WCF services from being accessed by other applications you will need to implement authentication of some sort Here is a related post

Custom hosting and "Silverlight-enabled WCF service"

I'd like my WP7 to be able to talk to a service on my local computer. For various reasons it would be more convenient if this service was hosted in a custom host, i.e. an app running locally. However, if I understand correctly "Silverlight-enabled WCF service" need asp.net compatibility, therefore must be hosted in IIS, is this correct?
If so, is there anyway to work round this and get a "Silverlight-enabled WCF service" running in a custom host?
The Silverlight-enabled WCF Service is just a simplified item template from a regular WCF service. It was originally added because the default binding for WCF services wasn't supported in Silverlight, and caused a lot of angst for new Silverlight developers. You should be able to use the regular WCF item in a regular project (e.g. console app) and you'll just have to adjust the bindings.
(Also of note is that the Silverlight-enabled WCF template uses a single code file instead of separating out the service interface from the class implementation.)

Is it reasonable to have both DomianService and Silverlight-enabled WCF Service

At the moment it seems that a RIA Domain Services class can not return a sinlge custom type.
There are parts of my app that needs just that, so think the only way to get that is to call back to a simple silverlight-enabled WCF Service, which i beleive will not have a problem returning a custom type. I don't see where the Silverlight client app has any sort of reference to the Ria Services. How do I set up both a Ria services and WCF service on the silverlight client. Will the WCF service be "aware" of the authenication already in place with the RIA services?
This is one of my biggest bugbears of RIA Services :). The good thing is that they are in the process of enabling complex types to be returned from invoke methods (according to the user voice site for RIA Services). However, that won't help you now :).
The best way to implement your requirement to return complex objects is indeed to set up a standard WCF Service to return complex types when required. You do so in the normal way that you would expose a WCF in any web project. You then consume it in your Silverlight application in much the same way you would a WCF Service in any other type of project (by adding it as a service reference). The main difference when consuming it (compared to other types of projects) is that Silverlight only supports asynchronous calls. One difference to be aware of from RIA Services is that whereas RIA Services automatically determines the URI of the domain services (based upon where the XAP file originated from), you will need to handle that aspect yourself (very important when you try to deploy your application :). Do this either by setting the URI in the app.config file, or use the method I use in the code accompanying this article here: http://www.silverlightshow.net/items/Building-a-Framework-for-Silverlight-Line-Of-Business-Applications.aspx.
In regards to your final question, yes, RIA Services uses standard ASP.NET authentication, so the cookie that it uses to maintain your authentication status is also used by any WCF Services in the same project. I talk a bit about security with WCF Services in this article if you want more information: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-3.aspx.
Hope this helps...
Chris

Resources