[ServiceContract]
public interface ISecurities<T> : IPolicyProvider where T: EntityObject
{
[OperationContract(Name="GetAllSecurities")]
IEnumerable<T> GetSecurities();
[OperationContract]
IEnumerable<T> GetSecurities<T1>(List<T1> lstIdentifiers) where T1 : FI_CusipMaster;
[OperationContract]
T GetSecurity<T1>(T1 lstIdentifiers) where T1 : FI_CusipMaster;
}
//Host
///CADIS Contract
ServiceHost dmHost = new System.ServiceModel.ServiceHost(typeof(GlobalInvestors.FIPA.BLL.UDI.CADISSecurities));
Uri baseAddress = dmHost.BaseAddresses[0];
Uri policyAddress = new Uri(baseAddress.AbsoluteUri.Replace(baseAddress.AbsolutePath, ""));
dmHost.AddServiceEndpoint(
typeof(GlobalInvestors.FIPA.BLL.IPolicyProvider),
new System.ServiceModel.WebHttpBinding(),
policyAddress).Behaviors.Add(new System.ServiceModel.Description.WebHttpBehavior());
dmHost.Open();
//App.Config
<service behaviorConfiguration="UDIBehaviour" name="GlobalInvestors.FIPA.BLL.UDI.CADISSecurities">
<endpoint binding="basicHttpBinding" contract="GlobalInvestors.FIPA.BLL.UDI.ICADISSecurities" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:1667/CADIS" />
</baseAddresses>
</host>
</service>
<behavior name="UDIBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
[ServiceContract]
[ServiceKnownType(typeof(SecurityMasterAdapter))]
public interface ICADISSecurities :ISecurities<SecurityMasterAdapter>
{
}
我得到「InvalidDataContractException類型‘System.Collections.Generic.List`1 [T1]’不能導出爲一個模式類型,因爲它是一個開放的泛型類型,你只能當導出一個泛型類型所有通用參數類型都是實際類型。「如果我主持這份合同。通用的ServiceContract
我已經讀過,很好的避免了在ServiceContract中的泛型。但是有可能使用T?
端點定義不正確。您已指定IPolicyProvider,因此您只能獲取在IPolicyProvider中定義的操作,而不是在ISecurities中定義的操作。 – 2010-08-17 15:40:27
你真棒!刪除IPolicyProvider,它工作。但ISecurities必須實施IPolicyProvider。我如何獲得這兩項業務? – Bhaskar 2010-08-17 15:50:44
您必須添加暴露ISecurities但具體指定具體類型的endpoit。 – 2010-08-17 15:53:16