Consumption of RIA services without silverlight project

We have a silverlight project that uses RIA services. There is some code that I want to share between this project and the web service. I have to leave the code where it is now, i.e. I can not use the code.

What I thought would be good is a web service that is called by the RIA service. It will sit on one server.

I went to my web service project and added a service link to the ria service. I clicked the “Advanced” button and checked the option “generate asynchronous operations”.

I thought everything would be fine, but I received some warnings. The client code that he generated did not contain any actual code related to asynchronous calls, and app.config is also empty. Here are the warnings

Warning 2 Custom tool warning: Cannot import wsdl:binding Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on. XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='CarServiceSoap'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_CarServiceSoap'] C:\Develop\DotNet\Trunk\Applications\WcfServices\CarTransmitter\CarTransmitter.Core\Service References\CarService\Reference.svcmap 1 1 CarTransmitter.Core Warning 3 Custom tool warning: Cannot import wsdl:port Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on. XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_CarServiceSoap'] XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='CarService']/wsdl:port[@name='BasicHttpBinding_CarServiceSoap'] C:\Develop\DotNet\Trunk\Applications\WcfServices\CarTransmitter\CarTransmitter.Core\Service References\CarService\Reference.svcmap 1 1 CarTransmitter.Core Warning 1 Custom tool warning: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter Error: Referenced type 'CarData.Organisation, CarData, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' with data contract name 'Organisation' in namespace 'http://schemas.datacontract.org/2004/07/CarData' cannot be used since it does not match imported DataContract. Need to exclude this type from referenced types. XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='CarServiceSoap'] C:\Develop\DotNet\Trunk\Applications\WcfServices\CarTransmitter\CarTransmitter.Core\Service References\CarService\Reference.svcmap 1 1 CarTransmitter.Core 
+4
source share
3 answers

Did not finish completely, got a little further. The problems that I'm having right now require a new question.

The solution to this problem is to disable the "reuse" options in referenced assemblies. When you add a link to a service, you click the "Advanced" button, and you get the option "reuse types in reference assemblies."

This is because I use the code between the two projects that I use, and he tried to "reuse" the objects that I had on my side in the common code. Instead, I just wanted it to create proxy objects for me and not reuse them.

0
source

Use the RIA Services project option to create your service library. This creates 2 projects that are related to each other (for the gen code of proxy objects). Both are actually just libs (1 Silverlight and 1.Net)

Link any RIA client library service to your Silverlight application. Then connect the .web RIA project to your web hosting (for standard use of RIA). You can also add the .web library to your Wcf service as a .Net lib (do not use it as a service).

If you did not create your main Silverlight project as an RIA services project, you will need to transfer the settings from the app.config file to the web.config file. If you already have the service support options, you just need to copy the db connection string. The db connection string should only be needed for a Wcf project.

Then you can either use the RIA calls on the server side (remember to add your own calls for subscriptions, as the RIA does this behind the scenes once per service pack), or simply use the data layer (EF, etc.).

+1
source

Yes. It can be done.

  • Creating a library project
  • Add LINQ to Entity Model
  • Add public class DomainService1: LinqToEntitiesDomainService
  • Check if your web.config looks like this

    [? xml version = "1.0"?] [Configuration] [configSections] [sectionGroup name = "system.serviceModel"] [section name = "domainServices" type = "System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices. Hosting, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31BF3856AD364E35 "allowDefinition =" MachineToApplication "requirePermission =" false "/] [/ SectionGroup] [/ ConfigSections]

    [system.webServer] [validation validateIntegratedModeConfiguration = "false" /] [modules runAllManagedModulesForAllRequests = "true"] [add name = "DomainServiceModule" preCondition = "managedHandler" type = "System.ServiceModel.DomainServices.Hosting.Service.Domain.Domain.ServiceModel.Domain .DomainServices.Hosting, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31BF3856AD364E35 "/] [/ Modules] [/system.webServer] [System.serviceModel] [DomainServices] [endpoints] [add name =" OData " type = "System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35" /] [add name = "soap" type = "Microsoft .ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 "/] [Add name =" JSO N "type =" Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 "/] [/ Endpoints] [/ DomainServices] [serviceHosting] aspNetCompatibilityEnabled = "true" multipleSiteBindingsEnabled = "true" /] [/system.serviceModel]

    [ConnectionStrings] [add name = "ASPNETDBEntities1" connectionString = "metadata = res: ///Model1.csdl | res: ///Model1.ssdl | res: //*/Model1.msl; provider = System.Data.SqlClient ; provider connection string = "data source = local host", initial directory = ASPNETDB; security information is saved = True: user ID = sa; password = your password; multipleactiveresultsets = True; App = EntityFramework "" providerName = "System.Data .EntityClient "/] [/ connectionStrings] [System.web] [assembly debug =" true "] [assemblies] [add assembly =" System.Data.Entity, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 " /] [/ assemblylies] [/ compilation] [/system.web] [/ Configuration]

    • Make the WEB publication locally and check the service link. Enjoy it!
0
source

All Articles