Могу ли я иметь один сервис с несколькими конечными точками и несколькими контрактами, используя дженерики.Я столкнулся с проблемой, когда метаданные не могут быть созданы (возможно, это просто проблема конфигурации и я не уверен, как должен выглядеть мой базовый адрес хоста):
namespace WCFSingleService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface ISingleService<T>
{
[OperationContract]
T GetData(T item);
}
}
namespace WCFSingleService
{
[ServiceContract(Name = "User")]
public interface IUserSingleService: ISingleService<User>
{
}
}
namespace WCFSingleService
{
[ServiceContract(Name = "Some")]
public interface ISomeSingleService: ISingleService<Some>
{
}
}
public partial class SingleService : IUserSingleService
{
public User GetData(User item)
{
//Do something
}
}
public partial class SingleService : ISomeSingleService
{
public Some GetData(Some item)
{
//Do something
}
}
Возможно ли это икак будет выглядеть конфигурация для этого сервиса?Кроме того, смогу ли я использовать службу, скажем, от клиента AJAX?Я полагаю, что сделал бы это, поскольку я не пытаюсь передать тип в контракт, и каждый контракт будет иметь свою конечную точку, верно?Спасибо!
Вот моя текущая конфигурация:
<system.serviceModel>
<services>
<service name="WCFSingleService.SingleService" behaviorConfiguration="WCFSingleService.ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8732/Design_Time_Addresses/WCFSingleService/SingleService" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="User" binding="wsHttpBinding" contract="WCFSingleService.IUserSingleService"/>
<endpoint address="Some" binding="wsHttpBinding" contract="WCFSingleService.ISomeSingleService"/>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFSingleService.ServiceBehavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
ОБНОВЛЕНИЕ: Ну, я пытался выяснить, почему мой сервак не сработал, как только я повернулсяотладка, которая открыла ошибку dorr.ДУХ!В любом случае, проблема, с которой я столкнулся, была связана с тем же именем метода, который создавался для обеих служб.Итак, кто-нибудь знает, как WCF переименовывает имена методов, если несколько служб влияют на один и тот же интерфейс?Есть ли декорация, которую я могу надеть на метод внутри одной из реализаций, чтобы он выглядел по-другому?