我们有一个使用 RIA 服务的 silverlight 项目。我想在该项目和 Web 服务之间共享一些代码。我必须将代码保留在现在的位置,即我无法共享代码。
我认为最好的方法是让 Web 服务调用 RIA 服务。它将位于同一服务器上。
我转到我的 Web 服务项目,并向 ria 服务添加了服务引用。我单击“高级”并勾选“生成异步操作”选项。
我以为一切顺利,但我收到了一些警告。它生成的客户端代码缺少与异步调用相关的任何实际代码,并且 app.config 也是空的。以下是警告,
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
使用 RIA 服务项目选项创建您的服务库。这将创建两个绑定在一起的项目(用于代理对象的代码生成)。两者实际上都只是库(1 个 Silverlight 和 1 .Net)
将任何 RIA 服务客户端库链接到您的 Silverlight 应用程序。然后将 .web RIA 项目链接到您的托管 Web 应用程序(用于标准 RIA 使用)。您还可以将 .web 库作为 .Net 库添加到 Wcf 服务(不将其作为服务使用)。
如果您没有将主 Silverlight 项目创建为 RIA 服务项目,则需要将设置从 app.config 文件移至 web.config 文件。如果您已经有了服务支持设置,则只需复制数据库连接字符串。仅 Wcf 项目需要数据库连接字符串。
然后,您应该能够使用服务器端 RIA 调用(不要忘记添加您自己的 commitchanges 调用,因为 RIA 在每批更新的幕后执行一次),或者直接使用数据层(EF 等) 。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)