1. Contracts
- Service Contract
- Data Contract
- Fault Contracts
- Message Contract
OperationContract : 반드시 Method에서만 구현 가능하다. 이는 WCF Model에서의 제약조건으로 가지고 있으며, 동작에 의해서 구현되는 모델의 기본 사양이 된다. (property 또는 index, value에서는 절대로 구현할 수 없다.)
1) Hosting
- WCF Service는 반드시 Host Process 안에서 구현되어야지 된다.
- Hosting 방법으로는 IIS를 이용하거나, Windows Application Service(WAS)를 이용하여 배포 가능하다.
C. WAS Hosting
2. Binding
2) TCP binding
- NetTcpBinding
- Cross machine communication on the internet
- optimized for WCF-WCF communication
3. EndPoints
- an address : where the service is
- binding : how to communicate with the service
- contract : what the service does
The endpoint is the fusion of the address, contract and binding
4. Metadata Exchange
HTTP-GET protocol을 이용한 metadata의 제공
WebService에서의 web browser를 이용한 Method view와 비슷한 내용을 제공한다.
5. Clint-Side Programming
2) SvcUtil : SvcUtil.exe (URL) /out:outputFileName.cs
- make a class then make the client configuration file required to interact with a service
- write service configuration with <system.serviceModel> <client> </client> </system.serviceModel>
<client> <endpoint address="http://localhost:8000/WCFProduct" binding="basicHttpBinding" bindingConfiguration="NewBinding0" contract="WCFProduct.IProduct" name="HttpHost"> <identity> <certificateReference storeName="My" storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" /> </identity> </endpoint> <endpoint address="http://localhost:8000/WCFProduct" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProduct" contract="WCFProduct.IProduct" name="BasicHttpBinding_IProduct" /> </client>
3) Generating the client config file
svcutil.exe http://localhost:8002/MyService /out:proxy.cs /config:app.config
4) Closing the proxy
//Method 1 : Declare open and close client.Open(); //Open proxy client.ListProducts(); client.Close(); //Close proxy //Method 2 : use using statement using ( client = new WCFCLient.WCFProduct.ProductClient()) { client.ListProducts(); } //Method 3 : Use IDisposable interface IDisposable disposable = client as IDisposable; if ( disposable != null ) { disposable.Dispose(); }
5) Programmatic Client Configuration
//Declare endpoint address with URL EndpointAddress endpointAddress = new EndpointAddress("http://localhost/WCFProduct/Service.svc"); //Declare Binding method : http, https, tcp .... WSHttpBinding wsBinding = new WSHttpBinding(); WCFProduct.ProductClient client = new WCFCLient.WCFProduct.ProductClient(wsBinding, endpointAddress);