.NET - WCF
기초
- WCF 기초(한글) http://akj61300.blog.me/80182137426
- WCF Step by Step http://blog.naver.com/saeparam/90024967440
- WAS에서 호스팅하기 http://blog.ruaa.me/23
- WCF로 만든 라이브러리를 다른 프로젝트에서 사용하기 http://www.codeproject.com/Articles/154870/WCF-Service-Library-A-Good-Approach-for-WCF-Servic
- WCF와 동시성 http://ruaa.tistory.com/20 http://ruaa.tistory.com/21
- WCF Concurrency (Single, Multiple, and Reentrant) and Throttling - 그림으로 잘 표현 http://www.codeproject.com/Articles/89858/WCF-Concurrency-Single-Multiple-and-Reentrant-and
- Task-based asynchronous operation in WCF http://www.codeproject.com/Articles/613678/Task-based-asynchronous-operation-in-WCF]
- WCF Hosting with Windows Service http://www.codeproject.com/Articles/653493/WCF-Hosting-with-Windows-Service
- How to Create SSL Secure Server (HTTPS) in Local IIS? http://www.codeproject.com/Tips/587443/How-to-create-SSL-secure-server-HTTPS-in-local-IIS
TCP
- High Performance WCF Services : netTcpBinding http://blog.shutupandcode.net/?p=1085
- 클라이언트에서 호출한 서버 함수에서 클라이언트 함수를 호출하는 경우는 OperationContract 선언시 단 뱡향임을 명시한다.
[OperationContract(IsOneWay = true)]
void Regist(string id);
- 리모트의 접속 끊어짐을 알기
리모트가 처음 요청할 때 이벤트를 등록한다.public void Regist(string id) { var ctx = OperationContext.Current; var client = ctx.GetCallbackChannel<IClientCallback>(); IClientChannel channel = client as IClientChannel; if (IsFirst) { // Faulted 와 Closed 둘 다 등록하면 리모트의 접속이 끊어지면 둘 다 이벤트가 호출되므로 하나만 등록 한다 // 네트워크 통신이 안될 때 호출 //OperationContext.Current.Channel.Faulted += new EventHandler(Channel_Faulted); // 클라이언트의 접속이 우아하게 종료되었을 때 호출 OperationContext.Current.Channel.Closed += new EventHandler(Channel_Closed); } }
응용
- 간단한 채팅 http://yamecoder.tistory.com/213
- 채팅 예제 http://wcfsimplechat.codeplex.com/
- WCF Hosting (3) - Windows Service를 이용한 Hosting http://devwith.com/?m=bbs&bid=teamblog_net&cat=WCF&where=subject%7Ctag&uid=1863
- Windows Communication Foundation 4.5의 새로운 기능 http://msdn.microsoft.com/ko-kr/library/dd456789(v=vs.110).aspx
- Getting Started with WCF 4.0 Routing Service http://www.codeproject.com/Articles/423064/Getting-Started-with-WCF-4-0-Routing-Service
- [wcf] 대용량 파일전송 WCF 구현 http://hackss.tistory.com/entry/wcf-%EB%8C%80%EC%9A%A9%EB%9F%89-%ED%8C%8C%EC%9D%BC%EC%A0%84%EC%86%A1-WCF-%EA%B5%AC%ED%98%84
- WCF Service Library with Windows Service Hosting http://www.codeproject.com/Articles/38160/WCF-Service-Library-with-Windows-Service-Hosting
http://handcraft.blogsite.org/Memo/Article/Archives/9 - WCF TCP-based File Server http://www.codeproject.com/Articles/33825/WCF-TCP-based-File-Server
- Peer to Peer File Sharing Through WCF http://www.codeproject.com/Articles/614028/Peer-to-Peer-File-Sharing-Through-WCF
- 클라이언트 IP 얻기
RES_RELOAD_GAME_DATA RequestGameDataReloading(REQ_RELOAD_GAME_DATA reqData)
{
var context = OperationContext.Current;
var prop = context.IncomingMessageProperties;
var endpoint = prop[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
string ipText = endpoint.Address;
}
설정 값
- self-host webbinding 예. App.config
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="ServerLib.ServerService">
<endpoint address="http://localhost:10501/Service"
binding="webHttpBinding"
contract="ServiceLib.IService"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior>
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Throttled">
<serviceThrottling maxConcurrentCalls="40000" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding
maxBufferPoolSize="64388608"
maxReceivedMessageSize="8000"
/>
</webHttpBinding>
</bindings>
</system.serviceModel>
<system.net>
<connectionManagement>
<add address = "*" maxconnection = "1000" />
</connectionManagement>
</system.net>
<runtime>
<gcServer enabled="true"/>
<gcConcurrent enabled="true"/>
</runtime>
</configuration>
WCF의 ServiceHost에 외부에서 객체 넘기기
- WCF의 서비스 클래스
[ServiceContract]
public interface IServerService
{
[OperationContract]
string Test();
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class ServerService : IServerService
{
ServerLogic MainLogic;
public ServerService(ServerLogic mainLogic)
{
MainLogic = mainLogic;
}
}
- 호스트 프로그램(콘솔이나 폼모드 혹은 서비스)에서 WCF 서비스 생성
void InitWCF()
{
MainLogic = new ServerLogic();
MainLogic.Init();
HostService = new WCFServerLib.ServerService(MainLogic);
// host 생성, address 지정
Host = new ServiceHost(HostService, new Uri("net.tcp://localhost/WCF/ServerService"));
// 종점 설정
Host.AddServiceEndpoint(
typeof(WCFServerLib.IServerService),
new NetTcpBinding(),
"");
// 호스트 open
Host.Open();
}
이 글은 2018-10-09에 작성되었습니다.