.NET : WCF

.NET 2010/02/04 17:34 Posted by Jay Choi

<WCF Step by Step>
  • DAAB 로 DB 연결

    • Microsoft patterns & practices : Enterprise Library : Enterprise Library Configuration 로 커넥션 스트링 생성 (web.config)
    • 참조

      Microsoft.Practices.EnterpriseLibrary.Data

      Microsoft.Practices.EnterpriseLibrary.Common

      Microsoft.Practices.ObjectBuilder2

  • web.config 설정 시 <configuration></configuration> 자식 노드로 <system.serviceModel> 노드 추가

    • serviceModel 예제 -> 각 노드 및 세부 애트리뷰트 정리 필요.

      <system.serviceModel>
          <services>

             <service name="Products.ProductsServiceImpl" behaviorConfiguration="ProductsBehavior">
                <endpoint address="" binding="basicHttpBinding" contract="Products.IProductsService" />
             </service>
         </services>
         <behaviors>
              <serviceBehaviors>
               <behavior name="ProductsBehavior">
                  <serviceDebug includeExceptionDetailInFaults="true" />  <!-- 개발 시 서비스 Debug 시 필요함.(삽질했음. 주의 할 것) -->
                  <serviceMetadata httpGetEnabled="true" />
               </behavior>
            </serviceBehaviors>
         </behaviors>
      </system.serviceModel>

  • Service Definition File (서비스와 같은 이름으로 생성. [프로젝트명.svc])

    • 예제

      <%@ ServiceHost Service = "Products.ProductsServiceImpl" Debug="true" %> <!-- Debug="true" 는 위에꺼 삽질하느라 임의로 넣었음. -->
      <%@ Assembly Name = "ProductsService" %>

  • 기본 구조

    • 데이터 계약

      [DataContract]

      public class Product {  }

    • 서 비스 계약

      [ServiceContract]

      public interface IProductsService {  }

    • 서 비스 계약 구현

      public class ProductsServiceImpl : IProductsService {  }

  • 참고 서적 및 사이트

 

 

이 글은 스프링노트에서 작성되었습니다.

TAG , ,