I have created a WCF RIA Services Class Library project which has a custom IDomainServiceFactory. Normally I would hook this up in Application_Start or something in a ASPNET project but this service will also be used by third parties via a SOAP endpoint so I need a way to create it automatically.
Only way I can think of is via web.config. Is this possible? I can't seem to find any documentation on domain services configuration settings.
You could do this programmatically in this fashion:
public void SomeConfigurationMethod()
{
DomainService.Factory = new YourDomainServiceFactory();
}
Related
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.
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
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.)
I have a silverlight app using RIA services. I want to reuse the RIA services component and call it from another web service. The web service and the RIA services component will be on the same server.
I have got quite far along, my web service project has a 'service reference' to the RIA services project which is all good. But when I call one of the RIA services methods I get the exception,
{DDB20766-F78A-42c7-B777-5ECF0AD9E4F3}Access to operation 'GetValidId' was denied.
at System.ServiceModel.DomainServices.Server.DomainService.ValidateMethodPermissions(DomainOperationEntry domainOperationEntry, Object entity)
The RIA services domain class has the attribute [RequiresAuthentication]. I am trying to understand how I can specify those credentials and authenticate?
Just as a test I commented out the attribute [RequiresAuthentication] and everything worked without any problems.
Check out this link:
http://www.ben-morris.com/using-the-wcf-authentication-service-without-cookies
Basically, you have to first successfully authenticate against your server, and have the server send back to you an authentication cookie that you can programatically add to subsequent requests to WCF RIA methods with [RequiresAuthentication] turned on.
Note, to get this to work, in your client program, when setting up WCF bindings to call your server WCF RIA methods, ensure allowCookies="false"; this will allow the code from the above link to actually be able to manually set the cookies in the header.
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