2012-01-15 4 views
5

두 개의 다른 클라이언트에 노출해야하는 IIS7 호스트 서비스가 있습니다. 클라이언트 중 하나는 다른 것보다 더 엄격한 제한 동작을 시행해야합니다.WCF 단일 서비스 구현, 다중 동작. 가능

이것은 두 개의 태그를 정의해야한다는 것을 의미하며 태그에서 참조 할 수 있기 때문에 이들 중 두 개가 필요합니까?

다음 web.config를 정의했습니다.

Parser Error Message: A child element named 'service' with same key already exists at the same configuration scope. 
Collection elements must be unique within the same configuration scope (e.g. the same application.config file). Duplicate key value: 'WCFTwoEndpoints.Calculate'. 

내가 이것에 대해 올바른 길을 가고 있는가 : 나는 내가 다음과 같은 오류가 다음 메타 데이터를 뽑을 수 있도록 하나의 서비스로 이동하려고 할 때 문제는 무엇입니까?

<system.serviceModel> 
    <services> 
     <service name="WCFTwoEndpoints.Calculate" behaviorConfiguration ="NotThrottled"> 
     <endpoint address="http://localhost/WCFTwoEndpoints/Calculate.svc" 
      binding="wsHttpBinding" bindingConfiguration="" name="Calculator" 
      contract="WCFTwoEndpoints.ICalculate" /> 
     <endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" /> 
     </service> 
     <service name="WCFTwoEndpoints.Calculate" behaviorConfiguration ="Throttled"> 
     <endpoint address="http://localhost/WCFTwoEndpoints/ThrottledCalculate.svc" 
      binding="wsHttpBinding" bindingConfiguration="" name="ThrottledCalculator" 
      contract="WCFTwoEndpoints.ICalculate" /> 
     <endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="NotThrottled"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     <behavior name="Throttled"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceThrottling maxConcurrentCalls="19" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
+0

는 Calculate.svc 및 ThrottledCalculate.svc – Rajesh

+0

예 나는 2 개 개의 다른 SVC는 파일을해야합니까라는 2 개 개의 다른 SVC는 파일을 가지고 있지만 그들은 같은 .cs에 둘 점은 내가 코드와 동일한 클래스 이름을 가진 같아요 –

+0

뒤에하면됩니다 WCF는 서비스 요소가 고유해야하며 동일한 이름을 가진 두 개의 서비스 요소가 있다고 예상하므로 문제가 발생합니다. 기능을 기본 클래스로 푸시 한 다음 다른 클래스에서 상속하여 서비스 이름을 고유하게 만들 수 있습니까? – Rajesh

답변

7

키의 이름이 서비스 클래스의 이름과 정확하게 일치해야하기 때문에 약간의 걸림돌이됩니다.

내가 생각할 수있는 유일한 방법은 WCFTwoEndpoints.Calculate에서 상속받은 새로운 클래스를 만드는 것입니다. 그렇다면 당신은 별개의 이름을 가질 것입니다. 그것은 매우 좋지 않다.

 

나는 그들이 이런 식으로 디자인 당신은 왜 WCF 디자이너를 요구한다면, 그들은 serivce가 클라이언트의 indepent되어있을 가능성 말을 생각합니다. 여기서 원하는 것은 실제로 하나의 서비스가 아닙니다. 그러나 두 가지의 서로 다른 독립적 인 서비스는 일률적으로 공통적으로 구현됩니다. 클라이언트의 관점에서 그들은 단일 서비스처럼 행동하지 않을 것입니다.

관련 문제