그래서 조직적인 문제로 인해 단일 인터페이스 계약을 처음으로 두 개의 분리 된 계약으로 분리했습니다. 이제는 두 인터페이스를 모두 구현하는 클래스가 하나 뿐이므로이를 WCF를 통해 REST 서비스로 모두 사용할 수있게하려고합니다. 계약은 다음과 같습니다 :"여러 필터가 일치했습니다."
1 :
[ServiceContract]
public interface INotification
{
[OperationContract]
[WebGet]
XElement GetInfo(string appID);
[OperationContract]
[WebGet]
void RegisterRID(string appID, string registrationID);
}
2 :
[ServiceContract]
public interface IPlanning
{
[OperationContract]
[WebGet]
XElement PlanTrip(string toDestination, string fromDestination, int year, int month, int day, int hour, int minute, string appID);
[OperationContract]
[WebGet]
XElement PlanTripDelayed(string toDestination, string fromDestination, int year, int month, int day, int hour, int minute, string appID);
[OperationContract]
[WebGet]
XElement PlanTripLoc(string toDestination, string fromLat, string fromLong, int year, int month, int day, int hour, int minute, string appID);
}
내의 app.config는 다음과 같습니다
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="RESTFriendly">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="TravelPlannerWebService.Domain.Entity.ETravelPlanner">
<endpoint binding="webHttpBinding" bindingConfiguration="" contract="TravelPlannerWebService.Acquaintance.IPlanning" behaviorConfiguration="RESTFriendly" />
<endpoint binding="webHttpBinding" bindingConfiguration="" contract="TravelPlannerWebService.Acquaintance.INotification" behaviorConfiguration="RESTFriendly" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:80" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
문제는, 두 개의 인터페이스를 사용할 때마다 오류가 발생합니다. 내 app_tracelog.svclog (app.config에서 의도적으로 여기에서 디버그 코드를 제거함)를 살펴보면 다음 오류가 발생합니다.
메시지 : 여러 개의 필터가 일치했습니다.
스택 추적 :
System.ServiceModel.Dispatcher.EndpointDispatcherTable.LookupInCache(Message message, Boolean& addressMatched)
System.ServiceModel.Dispatcher.EndpointDispatcherTable.Lookup(Message message, Boolean& addressMatched)
System.ServiceModel.Dispatcher.ChannelHandler.GetDatagramChannel(Message message, EndpointDispatcher& endpoint, Boolean& addressMatched)
System.ServiceModel.Dispatcher.ChannelHandler.EnsureChannelAndEndpoint(RequestContext request)
System.ServiceModel.Dispatcher.ChannelHandler.TryRetrievingInstanceContext(RequestContext request)
System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext request, OperationContext currentOperationContext)
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
System.Runtime.InputQueue`1.AsyncQueueReader.Set(Item item)
System.Runtime.InputQueue`1.EnqueueAndDispatch(Item item, Boolean canDispatchOnThisThread)
System.Runtime.InputQueue`1.EnqueueAndDispatch(T item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.SingletonChannelAcceptor`3.Enqueue(QueueItemType item, Action dequeuedCallback, Boolean canDispatchOnThisThread)
System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext context, Action callback)
System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult result)
System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContext(IAsyncResult result)
System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
System.Net.LazyAsyncResult.Complete(IntPtr userToken)
System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
System.Net.ListenerAsyncResult.WaitCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
나는이 문제를 해결하는 방법을 모른다. 내가 알 수있는 한, 다음 가이드에서, 이것은 여러 엔드 포인트에 대해 동일한 유형을 사용하는 올바른 방법입니다. 어떤 아이디어?
http://msdn.microsoft.com/en-us/library/aa395210.aspx의 예에서 서로 다른 계약이있는 두 개의 끝점에 대해 동일한 주소를 사용하기 때문에 이상합니다. –
아티클을 보면 값이 설정된 ListenUri 속성을 사용하고 있으며 해당 속성을 사용하면 동일한 주소에서 수신하는 다른 계약서를 사용할 수 있습니다. – Rajesh
좋아요, ListenUri가 둘 다 동일한 값을 갖고 있기 때문에 필요하지 않다고 생각했습니다. 그 접근법을 시도 할 것입니다. –