net.tcp 프로토콜사용하기 세팅하기

net.tcp 프로토콜을 사용하고자 하는 웹사이트에 바인딩을 추가합니다.

 

그리고 웹서비스가 사용될 폴더를 응용프로그램으로 변환합니다.

 

 

이폴더안에는   웹서비스가 들어있습니다.

 

 

명령어로 NET.TCP 활성화하기

net.tcp프로토콜을 추가하는 명령어 하지만 위에서 수동으로 입력했기때문에 패스


%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='19001:*']


net.tcp프로토콜활성화명령
 
위의 이미지처럼  설정(http => http,net.tcp)해주면 아래처럼 명령어를 입력 할 필요가 없다

%windir%\system32\inetsrv\appcmd.exe set app "Default Web Site/servicemodelsamples" /enabledProtocols:http,net.tcp

"Default Web Site" <—웹사이트 이름

"Default Web Site/servicemodelsamples" / 웹사이트 아래에 응용프로그램으로 변환했던 폴더명

 

활성화된 프로토콜 제거

%windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" --bindings.[protocol='net.tcp',bindingInformation='19001:*']

주의

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MarinerERP.WebService.DataService.InsaServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="MarinerERP.WebService.DataService.InsaServiceBehavior"
        name="MarinerERP.WebService.DataService.InsaService">
            <endpoint address="" binding="netTcpBinding" contract="IMarinerChannel.IInsaModule" />
        <endpoint address="mexTcp" binding="mexTcpBinding" contract="IMetadataExchange" />


      </service>
    </services>
  </system.serviceModel>
</configuration>

<endpoint address="" binding="netTcpBinding" contract="IMarinerChannel.IInsaModule" />
<endpoint address="mexTcp" binding="mexTcpBinding" contract="IMetadataExchange" />

IMetadataExchange 을 꼭 생성해주자
URL 은

msdn

http://msdn.microsoft.com/ko-kr/library/ms752218.aspx

 

이 샘플은 WAS에 의해 활성화된 작업자 프로세스에서 호스팅되는 서비스 라이브러리(.dll) 및 클라이언트 콘솔 프로그램(.exe)으로 구성됩니다. 콘솔 창에는 클라이언트 동작이 표시됩니다.

이 서비스는 요청-회신 통신 패턴을 정의하는 계약을 구현합니다. 다음 샘플 코드와 같이 계약은 수학 작업(Add, Subtract, Multifly 및 Divide)을 노출시키는 ICalculator 인터페이스에 의해 정의됩니다.

TCP 포트 공유가 설정되고 보안이 해제된 net.tcp 바인딩 변형이 샘플에 사용됩니다. 보안된 TCP 바인딩을 사용하려면 서버의 보안 모드를 원하는 설정으로 변경하고 클라이언트에서 Svcutil.exe를 다시 실행하여 업데이트 클라이언트 구성 파일을 생성합니다.

다음 샘플에서는 서비스에 대한 구성을 보여 줍니다.

<system.serviceModel>

    <services>
      <service name="Microsoft.ServiceModel.Samples.CalculatorService"
               behaviorConfiguration="CalculatorServiceBehavior">
        <!-- This endpoint is exposed at the base address provided by host: net.tcp://localhost/servicemodelsamples/service.svc  -->
        <endpoint binding="netTcpBinding" bindingConfiguration="PortSharingBinding"
          contract="Microsoft.ServiceModel.Samples.ICalculator" />
        <!-- the mex endpoint is explosed at net.tcp://localhost/servicemodelsamples/service.svc/mex -->
        <endpoint address="mex"
                  binding="mexTcpBinding"
                  contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <netTcpBinding>
        <binding name="PortSharingBinding" portSharingEnabled="true">
          <security mode="None" />
        </binding>
      </netTcpBinding>
    </bindings>

    <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
    <behaviors>
      <serviceBehaviors>
        <behavior name="CalculatorServiceBehavior">
          <serviceMetadata />
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>

 

  • Windows Communication Foundation 샘플의 일회 설치 절차를 수행했는지 확인합니다.

    또한 HTTP가 아닌 WCF 활성화 구성 요소를 설치해야 합니다.

    1. 시작 메뉴에서 제어판을 선택합니다.
    2. 프로그램 및 기능을 선택합니다.
    3. Windows 구성 요소 사용/사용 안 함을 클릭합니다.
    4. Microsoft .NET Framework 3.0 노드를 확장하고 Windows Communication Foundation 비-HTTP 활성화 기능을 선택합니다.
  • TCP 활성화를 지원하도록 WAS를 구성합니다.

    편의를 위해 다음 두 단계는 샘플 디렉터리에 있는 AddNetTcpSiteBinding.cmd라는 배치 파일에서 구현됩니다.

    1. net.tcp 활성화를 지원하려면 기본 웹 사이트를 먼저 net.tcp 포트에 바인딩해야 합니다. IIS(인터넷 정보 서비스) 7.0 관리 도구 집합과 함께 설치되는 Appcmd.exe를 사용하여 이 작업을 수행할 수 있습니다. 관리자 수준 명령 프롬프트에서 다음 명령을 실행합니다.

      %windir%\system32\inetsrv\appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']

      참고: 이 명령은 줄 바꿈 없이 한 줄로 입력해야 합니다. 이 명령은 임의의 호스트 이름을 사용하여 TCP 포트 808에서 수신 대기하는 기본 웹 사이트에 net.tcp 사이트 바인딩을 추가합니다.

    2. 사이트 내의 모든 응용 프로그램이 공통된 net.tcp 바인딩을 공유하지만 각 응용 프로그램에서는 개별적으로 net.tcp 지원을 사용하도록 설정할 수 있습니다. /servicemodelsamples 응용 프로그램에 대해 net.tcp를 사용하도록 설정하려면 관리자 수준 명령 프롬프트에서 다음 명령을 실행합니다.

      %windir%\system32\inetsrv\appcmd.exe set app
      "Default Web Site/servicemodelsamples" /enabledProtocols:http,net.tcp

    + Recent posts