由于公司要开发WinForm,WPF,SL版的搜索引擎,这是需要把搜索代码和service层和具体的项目decouple.
MODEL+DomainService <---->Query <------>WPF,WinForm;MODEL+DomainService <---->SL.
Query引用DomainService具体操作如下
1.在web项目中添加引用
Microsoft SDKs\RIA Services\v1.0\Toolkit\Libraries\Server\Microsoft.ServiceModel.DomainServices.Hosting.dll
2.在webconfig里面添加
<system.serviceModel>
<domainServices>
<endpoints>
<add name="Soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Json" type="Microsoft.ServiceModel.DomainServices.Hosting.JsonEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="OData" type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, System.ServiceModel.DomainServices.Hosting.OData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</endpoints>
</domainServices>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
3.在Query项目中添加service 引用。引用的路径
http://yourServerName:port/services/serviceNameSpace-web-servicename.svc