2012-03-14 3 views
0

wcf 서비스 호스트를 준비하고 아래의 바인딩 정보로 구성했습니다.서비스 참조 추가로 클라이언트에 WCF 호스트 구성을 가져올 수 없습니다.

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    <standardEndpoints> 
    <webHttpEndpoint> 
    <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" /> 
    </webHttpEndpoint> 
    </standardEndpoints> 
    <bindings> 
    <netTcpBinding> 
    <binding name="NetTcpBinding" closeTimeout="00:02:00" openTimeout="00:02:00" 
     receiveTimeout="00:20:00" sendTimeout="00:02:00" transactionFlow="true" 
     transferMode="Buffered" maxBufferPoolSize="2147483647" 
     maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> 
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
     maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
     maxNameTableCharCount="2147483647" /> 
     <security mode="None"> 
     <transport protectionLevel="None" /> 
     </security> 
    </binding> 
    </netTcpBinding> 
    </bindings> 
    <behaviors> 
    <serviceBehaviors> 
    <behavior name="tcpServiceBehavior"> 
     <serviceMetadata httpGetEnabled="false" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <services> 
    <service behaviorConfiguration="tcpServiceBehavior" name="MyClass"> 
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="IMyClass"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" /> 
     </baseAddresses> 
    </host> 
    </service> 
    </services> 
</system.serviceModel> 

그리고 아래의 코드로 인스턴스화 : 간략한 사용

ServiceHost wcfHost = new ServiceHost(typeof(MyClass)); 
wcfHost.Open(); 

그것을 체크 아웃하고 구성 값을 확인했습니다. 그런 다음 "net.tcp : // localhost : 8732/Design_Time_Addresses/MyService/MyClass"의 서비스 참조를 다른 프로젝트에 추가했습니다. 그래서 아래의 새로운 설정 파일이 클라이언트 프로젝트에 생성되었습니다.

<system.serviceModel> 
    <bindings> 
    <netTcpBinding> 
     <binding name="NetTcpBinding_IMyClass" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
     transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" 
     hostNameComparisonMode="StrongWildcard" listenBacklog="10" 
     maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" 
     maxReceivedMessageSize="65536"> 
     <readerQuotas maxDepth="32" maxStringContentLength="8192" 
       maxArrayLength="16384" maxBytesPerRead="4096" 
       maxNameTableCharCount="16384" /> 
     <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> 
     <security mode="None"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
      <message clientCredentialType="Windows" /> 
     </security> 
     </binding> 
    </netTcpBinding> 
    </bindings> 
    <client> 
    <endpoint address="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyClass" contract="IMyClass" name="NetTcpBinding_IMyClass"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    </client> 
</system.serviceModel> 

문제는 호스트의 바인딩 구성이 클라이언트에 제공 될 수 없다는 것입니다. 클라이언트 구성을 변경하더라도 영향을주지 않습니다. 예를 들어, maxStringContentLength 값을 부터 으로 변경 한 경우 해당 클라이언트가 올바른 구성으로 인스턴스화되었지만 이전 구성으로 작동한다는 것을 알았습니다. 솔루션에서 ""을 (를) 검색하여 .svcinfo 개의 파일을 XML 스키마로 찾았습니다. 이 이상한 상황을 어떻게 해결할 수 있습니까?

답변

0

서비스 참조를 마우스 오른쪽 단추로 클릭하면 VS가 svcinfo 파일을 다시 생성합니다. 그렇지 않으면 VS를 사용하지 않고 서비스 프록시를 만들고 수동으로 자체 서비스 프록시를 생성하여이 문제를 완전히 피할 수 있습니다 내가 아는 한 최선의 방법). 이미 언급했듯이 "서비스 참조 추가"는 클라이언트를 만들 때 서비스에서 모든 구성 값을 가져올만큼 똑똑하지 않습니다.

관련 문제