2009-07-22 6 views
2

WCF 구성 설정에 대한 기본 지침이 필요합니다. 이것은 WCF (및 첫 번째 게시물 stackoverflow에 대한) 내 첫 번째 심각한 노력입니다.WCF에서 여러 서비스 끝점을 어떻게 구성합니까?

나는 내 웹 프로젝트 에서 참조하는 WCF 클래스 라이브러리 (APILibrary)를 가지고 있습니다. wcf 라이브러리에는 현재 IAuthService 및 ITradeService라는 두 개의 서비스가 있습니다.

1) 내 문제 (이 게시물에 대한 원래의 이유) 내 응용 프로그램을 컴파일 때 나는 TradeServiceCient 호출 할 수 오전입니다하지만 AuthServiceClient :

이 라인을 따라

, 나는 세 가지 질문이 내 웹 앱에서. 후자는 인텔리 센스에 나타나지 않습니다. 나는 그들이 동일한 포트 (그리고 단 하나의 엔드 포인트 만 포함)를 공유하고 있다는 사실과 관련이 있다는 느낌이 들지만 분명히 분명하다. 불분명 함.

2) 개발 및 테스트하는 동안 동시에 두 개의 서비스 엔드 포인트를 노출하려고 시도하고 있습니다 (그리고 ). 스테이징으로 이동하고 호스팅 할 때 각 끝점에는 자체 주소가 있습니다. 그때까지, 어떻게합니까 나는 이것을합니까 (나는 이것이 나의 질문과 관련이 있다고 느낀다)?

3) 많은 사람들이 "클라이언트" 과 "server" "system.serviceModel"코드의 예제를 가지고 있다는 것을 눈치 채고 있습니다. 내 WCF 라이브러리에있는 App.config 파일의 이러한 고유 한 파일 또는 태그 이 있습니까? 각각 무엇을하고 있습니까? 현재 저는 서버 쪽만 가지고 있다고 생각합니까? 여기

이 (내 WCF 라이브러리) 나는 현재 내 app.config 파일에있는 것입니다 :

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <client /> 
    <services> 
     <service behaviorConfiguration="ApiLibrary.ApiBehavior" name="SpoonSys.Api.Trade.TradeService"> 
     <endpoint address="" binding="wsHttpBinding" contract="SpoonSys.Api.Trade.ITradeService"> 
      <identity> 
      <dns value="localhost:8731" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/Design_Time_Addresses/ApiLibrary/Trade/" /> 
      </baseAddresses> 
     </host> 
     </service> 

     <service behaviorConfiguration="ApiLibrary.ApiBehavior" name="SpoonSys.Api.Authentication.AuthService"> 
     <endpoint address="" binding="wsHttpBinding" contract="SpoonSys.Api.Authentication.IAuthService"> 
      <identity> 
      <dns value="localhost:8731" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/Design_Time_Addresses/ApiLibrary/Authentication/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ApiLibrary.ApiBehavior"> 
      <!-- 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="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

내 구성이 ASP.NET/프레임 워크 3.5/VS 2008/C#

+0

@marc_s says _ "다른 질문은 인텔리 센스에서 하나의 엔드 포인트 만 볼 수있는 이유입니다. 두 엔드 포인트 모두에 클라이언트 프록시를 작성 했습니까? 두 개의 별도 계약이므로 두 개의 개별 클라이언트 프록시가 필요합니다. 클라이언트 엔드 포인트를 작성 했습니까? 또한 클라이언트 구성 설정을 게시 할 수 있습니까? " – Kiquenet

답변

4

예, 귀하의 경우에는 서버 측만 다루기 때문에 구성이 매우 좋아 보입니다.

내가 설정에서 변경할 유일한 것은 "baseAddress"와 실제 서비스 주소 사이의 구분입니다. 현재 기본 주소의 전체 주소를 정의합니다. 기본 주소의 목적을 상실하는 것입니다. 내가 지금처럼 분할 것 :

<service name="SpoonSys.Api.Services" 
      behaviorConfiguration="ApiLibrary.ApiBehavior" > 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8731/Design_Time_Addresses/ApiLibrary/" /> 
     </baseAddresses> 
    </host> 
    <endpoint 
     address="Trade" 
     binding="wsHttpBinding" 
     contract="SpoonSys.Api.Trade.ITradeService"> 
     <identity> 
     <dns value="localhost:8731" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 

그런 식으로, 당신은 기본적으로 하나에 당신의 두 끝점을 축소 할 수 - 기본 주소는 그냥 정의 - 공통 기본을 다른 모든 주소에 대해 - 엔드 포인트가 세부 사항을 정의하면서 전체 주소의 :이 서비스 계약을 모두 구현하는 하나의 서비스 클래스 "SpoonSys.Api.Services"이 경우

<service name="SpoonSys.Api.Services" 
      behaviorConfiguration="ApiLibrary.ApiBehavior" > 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8731/Design_Time_Addresses/ApiLibrary/" /> 
     </baseAddresses> 
    </host> 
    <endpoint 
     address="Trade" 
     binding="wsHttpBinding" 
     contract="SpoonSys.Api.Trade.ITradeService"> 
     <identity> 
     <dns value="localhost:8731" /> 
     </identity> 
    </endpoint> 
    <endpoint 
     address="Authentication" 
     binding="wsHttpBinding" 
     contract="SpoonSys.Api.Authentication.IAuthService"> 
     <identity> 
     <dns value="localhost:8731" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 

이 작동 - 그 완전히 벌금과 시간에 매우 유용합니다.

각각 하나의 인터페이스를 구현하는 두 개의 별도 서비스 클래스가 있어야하는 경우 다음과 같이 구성을 축소 할 수 없습니다. 그러면 두 개의 개별 서비스 클래스에 대해 전체 구성을 사용해야합니다. 원래 게시물 (나에게 잘 보였다).

다른 질문은 인텔리 센스에서 하나의 엔드 포인트 만 보게되는 이유입니다. 두 엔드 포인트 모두에 클라이언트 프록시를 작성 했습니까? 두 개의 별도 계약이므로 두 개의 별도 클라이언트 프록시가 필요합니다. 어떻게 클라이언트 엔드 포인트를 만들었습니까? 클라이언트 구성도 게시 할 수 있습니까?

마크

0

귀하의 제안에 따라 기본 주소를 줄였습니다. 그런 다음 하나의 서비스가 시작되지만 다른 서비스는 시작되지 않는 오류가 발생했습니다. 나는 메타 데이터 엔드 포인트가 이미 사용되고 있다고 들었다. 그런 다음 SpoonSys.ApiLibrary.AutLicense.AutLibrary.ApiLibrary.Trade에서 모든 클래스 파일에 대해 SpoonSys.ApiLibary 으로 내 네임 스페이스를 변경해 보았습니다. 여전히 - 같은 오류. 원래 서버 구성으로 다시 변경했을 때 컴파일되었습니다. 아직도, 인텔리 센스는 단지 하나의 서비스 만받는 것이지 다른 하나는 받아들이지 않습니다.

내 클라이언트 구성 파일에 어떤 의미가 있는지 잘 모르겠습니다. 클라이언트 응용 프로그램 프로젝트에서 WCF와 관련하여 특별한 작업을 수행하지 않았습니다 (WCF 클래스 라이브러리를 웹 서비스 참조로 가져 오는 것을 제외하고). 어쩌면 내가 잘못 가고있는 것일까? 여기 좀 더 말해 줄래?

나는 각 엔드 포인트에 대한 WCF 편집기에서 Client.dll를 발견하고 그 아래에 게시 한 :

끝점 : 로컬 호스트 : 8731/Design_Time_Addresses/인증/MEX

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="WSHttpBinding_ITradeService" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
        allowCookies="false"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
        <security mode="Message"> 
         <transport clientCredentialType="Windows" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="Windows" negotiateServiceCredential="true" 
          algorithmSuite="Default" establishSecurityContext="true" /> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="localhost:8731/Design_Time_Addresses/Trade/" 
       binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITradeService" 
       contract="ITradeService" name="WSHttpBinding_ITradeService"> 
       <identity> 
        <dns value="localhost:8731" /> 
       </identity> 
      </endpoint> 
     </client> 
    </system.serviceModel> 
</configuration> 

엔드 포인트 : http://localhost:8731/Design_Time_Addresses/Trade/mex

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="WSHttpBinding_IAuthService" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
        allowCookies="false"> 
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
        <reliableSession ordered="true" inactivityTimeout="00:10:00" 
         enabled="false" /> 
        <security mode="Message"> 
         <transport clientCredentialType="Windows" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="Windows" negotiateServiceCredential="true" 
          algorithmSuite="Default" establishSecurityContext="true" /> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="localhost:8731/Design_Time_Addresses/Authentication/" 
       binding="wsHttp binding" bindingConfiguration="WSHttpBinding_IAuthService" 
       contract="IAuthService" name="WSHttpBinding_IAuthService"> 
       <identity> 
        <dns value="localhost:8731" /> 
       </identity> 
      </endpoint> 
     </client> 
    </system.serviceModel> 
</configuration> 

그리고 마지막으로, 여기 내 app.config에 다시입니다 :

,
<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service behaviorConfiguration="ApiLibrary.ApiBehavior" 
     name="SpoonSys.ApiLibrary.Trade.TradeService"> 
     <endpoint address="" binding="wsHttpBinding" contract="SpoonSys.Api.Trade.ITradeService"> 
      <identity> 
      <dns value="localhost:8731" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8731/Design_Time_Addresses/Trade/" /> 
      </baseAddresses> 
     </host> 
     </service> 
     <service behaviorConfiguration="ApiLibrary.ApiBehavior" 
     name="SpoonSys.Api.Authentication.AuthService"> 
     <endpoint address="" binding="wsHttpBinding" contract="SpoonSys.ApiLibrary.Authentication.IAuthService"> 
      <identity> 
      <dns value="localhost:8731" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="localhost:8731/Design_Time_Addresses/Authentication/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ApiLibrary.ApiBehavior"> 
      <!-- 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="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

PS - 내 응답을 제출하려고 할 때 "새 사용자가 최대 하나의 하이퍼 링크 만 게시 할 수 있습니다."라는 메시지가 나타납니다. 내 게시물의 모든 "http : //"참조를 제거했습니다. 코드 오류가 아닙니다.

관련 문제