Default NetTcp Binding
이 샘플에서는 NetTcpBinding 바인딩을 사용하는 방법을 보여 줍니다. 이 샘플은 계산기 서비스를 구현하는 Getting Started 샘플을 기반으로 합니다. 이 샘플에서 서비스는 자체 호스팅됩니다. 서비스와 클라이언트 모두 콘솔 응용 프로그램입니다.
참고
이 샘플의 설치 절차 및 빌드 지침은 이 항목의 끝부분에 나와 있습니다.
클라이언트와 서비스에 대한 구성 파일에 바인딩이 지정됩니다. 다음 샘플 구성과 같이 <endpoint> 요소의 binding 특성에 바인딩 형식이 지정됩니다.
<endpoint address=""
binding="netTcpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
위의 샘플에서는 기본 설정과 함께 netTcpBinding 바인딩을 사용하도록 끝점을 구성하는 방법을 보여 줍니다. netTcpBinding 바인딩을 구성하고 일부 설정을 변경하려면 바인딩 구성을 정의해야 합니다. 끝점은 bindingConfiguration 특성이 있는 이름으로 바인딩 구성을 참조해야 합니다. 이 샘플에서 바인딩 구성은 이름이 Binding1
로 지정되며 다음 샘플 구성과 같이 정의됩니다.
<services>
<service name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
...
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="Binding1"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
...
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="Binding1"
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="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
</security>
</binding>
</netTcpBinding>
</bindings>
샘플을 실행하면 작업 요청 및 응답이 클라이언트 콘솔 창에 표시됩니다. 클라이언트를 종료하려면 클라이언트 창에서 Enter 키를 누릅니다.
Add(100,15.99) = 115.99
Subtract(145,76.54) = 68.46
Multiply(9,81.25) = 731.25
Divide(22,7) = 3.14285714285714
Press ENTER to terminate client.
샘플을 설치, 빌드 및 실행하려면
Windows Communication Foundation 샘플의 일회 설치 절차를 수행했는지 확인합니다.
C# 또는 Visual Basic .NET 버전의 솔루션을 빌드하려면 Windows Communication Foundation 샘플 빌드의 지침을 따릅니다.
단일 컴퓨터 또는 다중 컴퓨터 구성에서 샘플을 실행하려면 Windows Communication Foundation 샘플 실행의 지침을 따릅니다.
참고
서버가 자체 호스팅되므로 샘플을 다중 컴퓨터 구성에서 실행하려면 클라이언트의 App.config 파일에 ID를 지정해야 합니다.
<client> <endpoint name="" address="net.tcp://servername:9000/servicemodelsamples/service" binding="netTcpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator"> <identity> <userPrincipalName value = "user_name@service_domain"/> </identity> </endpoint> </client>
Send comments about this topic to Microsoft.
© 2007 Microsoft Corporation. All rights reserved.