Dual Http 샘플에서는 WSDualHttpBinding 바인딩을 구성하는 방법을 보여 줍니다. 이 샘플은 IIS(인터넷 정보 서비스)에 의해 호스팅되는 클라이언트 콘솔 프로그램(.exe) 및 서비스 라이브러리(.dll)로 구성됩니다. 서비스는 이중 계약을 구현합니다. 계약은 수학 연산(Add, Subtract, Multiply 및 Divide)을 노출하는 ICalculatorDuplex
인터페이스에 의해 정의됩니다. 이 샘플에서 클라이언트는 ICalculatorDuplex
인터페이스를 통해 수학 연산을 수행하고 세션 중에 실행 결과를 계산할 수 있습니다. 서비스는 독립적으로 ICalculatorDuplexCallback
인터페이스에 결과를 반환합니다. 클라이언트와 서비스 간에 전송되는 메시지 집합을 서로 연결하기 위해 컨텍스트를 설정해야 하므로 이중 계약에는 세션이 필요합니다. WSDualHttpBinding 바인딩은 이중 통신을 지원합니다.
![]() |
---|
이 샘플의 설치 절차 및 빌드 지침은 이 항목의 끝부분에 나와 있습니다. |
![]() |
---|
컴퓨터에 이 샘플이 이미 설치되어 있을 수도 있습니다. 계속하기 전에 다음(기본) 디렉터리를 확인하십시오.
<InstallDrive>:\WF_WCF_Samples
이 디렉터리가 없으면 Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4로 이동하여 WCF(Windows Communication Foundation) 및 WF 샘플을 모두 다운로드하십시오. 이 샘플은 다음 디렉터리에 있습니다.
<InstallDrive>:\WF_WCF_Samples\WCF\Basic\Binding\WS\DualHttp
|
WSDualHttpBinding을 사용하여 서비스 끝점을 구성하려면 다음과 같이 끝점 구성에 바인딩을 지정합니다.
<endpoint address=""
binding="wsDualHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculatorDuplex" />
클라이언트에서는 다음 샘플 구성과 같이 서버가 클라이언트에 연결하는 데 사용할 수 있는 주소를 구성해야 합니다.
<system.serviceModel>
<client>
<endpoint address=
"https://localhost/servicemodelsamples/service.svc"
binding="wsDualHttpBinding"
bindingConfiguration="Binding1"
contract="Microsoft.ServiceModel.Samples.ICalculatorDuplex" />
</client>
<bindings>
<!-- Configure a WSDualHttpBinding that supports duplex -->
<!-- communication. -->
<wsDualHttpBinding>
<binding name="Binding1"
clientBaseAddress="https://localhost:8000/myClient/"
useDefaultWebProxy="true"
bypassProxyOnLocal="false">
</binding>
</wsDualHttpBinding>
</bindings>
</system.serviceModel>
샘플을 실행하면 작업 요청 및 응답이 클라이언트 콘솔 창에 표시됩니다. 클라이언트를 종료하려면 클라이언트 창에서 Enter 키를 누릅니다.
Press <ENTER> to terminate client once the output is displayed.
Result(100)
Result(50)
Result(882.5)
Result(441.25)
Equation(0 + 100 - 50 * 17.65 / 2 = 441.25)
샘플을 실행하면 서비스에서 전송된 콜백 인터페이스에서 클라이언트에 반환된 메시지를 볼 수 있습니다. 각 중간 결과가 표시된 다음 모든 작업이 완료되면 전체 수식이 표시됩니다. 클라이언트를 종료하려면 Enter 키를 누릅니다.
샘플을 설치, 빌드 및 실행하려면
다음 명령을 사용하여 ASP.NET 4.0을 설치합니다.
%windir%\Microsoft.NET\Framework\v4.0.XXXXX\aspnet_regiis.exe /i /enable
Windows Communication Foundation 샘플의 일회 설치 절차를 수행했는지 확인합니다.
C# 또는 Visual Basic .NET 버전의 솔루션을 빌드하려면 Windows Communication Foundation 샘플 빌드의 지침을 따릅니다.
단일 컴퓨터 또는 다중 컴퓨터 구성에서 샘플을 실행하려면 Running the Windows Communication Foundation Samples의 지침을 따릅니다.
참고:
다중 컴퓨터 구성에서 클라이언트를 실행할 경우에는 다음과 같이 endpoint 요소의 address 특성과 wsDualHttpBinding 요소에서 binding 요소의 clientBaseAddress 특성에서 localhost를 해당 컴퓨터의 이름으로 바꾸어야 합니다. <client> <endpoint name = "" address= "http://service_machine_name/servicemodelsamples/service.svc" /> </client> ... <wsDualHttpBinding> <binding name="DuplexBinding" clientBaseAddress= "http://client_machine_name:8000/myClient/"> </binding> </wsDualHttpBinding>