2013-08-26 4 views
0

WCF 서비스 프로젝트를 만들었습니다. SVC 파일에 다음 내용이 있습니다.Windows 서비스로 WCF 서비스 호스팅

<%@ ServiceHost Service="Deepak.BusinessServices.Implementation.ApiImplementation" 
     Factory="Deepak.BusinessServices.Implementation.CustomServiceHostFactory"%> 

SVC 참조

http://localhost/DeepakGateway/Service.svc 

서비스 UP 및 WSDL을 생성한다. 이제이 서비스를 Windows 서비스로 호스팅하려고합니다. 어떻게해야합니까?

"Windows 서비스"를 만들었습니다. 프로젝트에는 다음 코드가 있습니다.

protected override void OnStart(string[] args) 
    { 
     if (m_Host != null) 
     { 
      m_Host.Close(); 
     } 
     Uri httpUrl = new Uri("http://localhost/DeepakGateway/Service.svc"); 

     m_Host = new ServiceHost 
     (typeof(?????? WHAT TO FILL HERE?), httpUrl); 
     //Add a service endpoint 
     m_Host.AddServiceEndpoint 
     (typeof(?????? WHAT TO FILL HERE?),), new WSHttpBinding(), ""); 
     //Enable metadata exchange 
     ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); 
     smb.HttpGetEnabled = true; 
     m_Host.Description.Behaviors.Add(smb); 
     //Start the Service 
     m_Host.Open(); 


    } 

답변

0

당신은 뭔가를 보이는 당신의 서비스 구현 클래스를 가정하여 AddServiceEndpoint

서비스 계약의하여 ServiceHost 생성자의 서비스 계약을 구현하는 클래스의 유형 및 유형을 추가 할 필요가 같은 :

namespace Deepak.BusinessServices.Implementation 
{ 
    public class ApiImplementation : IApiImplementation 
    { 
     .... 
    } 
} 

는 당신이 필요합니다

m_Host = new ServiceHost(typeof(ApiImplementation), httpUrl); 
m_Host.AddServiceEndpoint(typeof(IApiImplementation), new WSHttpBinding(), ""); 
  • 서비스 클래스의 어떤 (콘크리트) 유형을 알 필요가서비스 호스트 호스트 연결
  • 서비스 계약 (인터페이스)가 노출 무엇인지 알 필요가엔드 포인트
+0

선택할 수있는 서비스 계약이 많이 있습니다! –

+0

@IsharehappyK :이 엔드 포인트에서 폭로하고 싶은 것 .... –

관련 문제