본문 바로가기
개발/.NET

[WCF] Ajax 를 이용한 WCF 호출을 위한 설정.

by 그저그런보통사람 2010. 10. 21.
* Web.Config
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/><!-- asp.net 상호작용을 위한 설정 -->
    <behaviors>      
      <serviceBehaviors>
        <behavior name="StatisticsServiceBehavior">            
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />          
        </behavior>        
      </serviceBehaviors>
      <endpointBehaviors><!-- 스크립트를 통한 동작 허용 설정 -->
        <behavior name="StatisticsServiceAjaxBehavior"><
          <enableWebScript/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service name="Infotops.LMS.WebSite.AdminSite.Services.StatisticsService" 
               behaviorConfiguration="StatisticsServiceBehavior">
        <endpoint behaviorConfiguration="StatisticsServiceAjaxBehavior" 
                  address="" 
                  binding="webHttpBinding" 
                  contract="Infotops.LMS.WebSite.AdminSite.Services.IStatisticsService">
        </endpoint><!-- 종점 바인딩 설정 -->
      </service>
    </services>
  </system.serviceModel>

* SVC
[ServiceContract(Namespace="http://www.ilat.kr/")]
public interface IStatisticsService {
        [OperationContract]
        [WebInvoke(BodyStyle=WebMessageBodyStyle.WrappedRequest,Method="POST")]
        string GetStudyResultReportList(string companyId, string studyStartDate);
}

[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
public class StatisticsService : IStatisticsService {

        public string GetStudyResultReportList(string companyId, string studyStartDate)
        {
               return string.Empty;
        }
}