2012-07-31 3 views
2

성 WCF 통합 기능을 사용하고 있으며 첫 번째 웹 HTTP 끝점에 대해 제대로 작동하고 있습니다. 이 엔드 포인트가 작동하려면 엔드 포인트에 WebHttpBehavior가 사용 가능해야합니다.성 WCF 통합 기능 지정하기 끝점 별 끝점 동작

  container.Register(Component.For<IEndpointBehavior>() 
          .ImplementedBy<WebHttpBehavior>()); 

이것은 문제가된다 나는 WebHttpBehavior와 호환되지 않습니다은 BasicHttpBinding을 사용하여 두 번째 엔드 포인트를 사용하려고하면 내가 사용하여이를 달성 할 수 있었다.

위의 IEndPointBehavior 등록이 특정 끝점에만 적용될 수 있음을 지정하는 데는 어느 정도의 시간이 필요합니까?

이 서비스에 대한 내 전체 설치 프로그램입니다 :

  container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero) 
       .Register(Component.For<IDiagnosticService>() 
        .ImplementedBy<DiagnosticService>() 
        .Named("DiagnosticService") 
        .LifestyleTransient() 
        .AsWcfService(new DefaultServiceModel() 
            .Hosted() 
            .AddEndpoints(WcfEndpoint.BoundTo(new WebHttpBinding()).At("json")) 
            .AddEndpoints(WcfEndpoint.BoundTo(new BasicHttpBinding()).At("soap")) 
            .PublishMetadata(o => o.EnableHttpGet()))); 


      container.Register(Component.For<IEndpointBehavior>() 
          .ImplementedBy<WebHttpBehavior>()); 
+0

WcfEndpoint 클래스는 System.ServiceModel.ServiceEndpoint의 인스턴스를 허용합니다

여기 내 작업 설치 프로그램입니다. 이를 사용하여 필요에 따라 엔드 포인트를 독립적으로 구성 할 수 있습니다. 이것은 올바르게 작동하는 것처럼 보이지만 상대 주소 지정 (예 : http : //local/ser.svc/json vs (http : //local/ser.svc/soap))을 처리하는 방법을 알 수는 없습니다 System.ServiceModel.EndpointAddress는 URI가 필요합니다. 전체 uri (http : //local/ser.svc/json ")를 입력하면"No protocol binding matches "예외가 발생합니다. 단지 http : // local을 사용하면 /ser.svc를 URI로 사용하면 작동하지만,/json 및/soap 끝점 주소가 없습니다. – Bluffrock

답변

3

좋아. 나는 마침내 이것을 알아 냈다. 내 문제의 대부분은 Castle WCF Integration보다는 Azure 에뮬레이션 환경과 관련이 있다고 밝혀졌습니다. 대답은 꽤 간단합니다. ServiceEndpoint 인스턴스를 설정하고 WcfEndpoint.FromEndpoint() 메서드를 사용하면됩니다.

 String internalEndpointAddress = string.Format("http://{0}/DiagnosticService.svc", 
              RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"].IPEndpoint); 

     // This ContractDescription instance must be used for both endpoints in this case 
     ContractDescription description = ContractDescription.GetContract(typeof(IDiagnosticService)); 

     // Create JSON webHTTP Binding    
     WebHttpBinding webhttpbinding = new WebHttpBinding(); 
     string jsonURI = internalEndpointAddress + "/json"; 
     EndpointAddress jsonEndpointAddress = new EndpointAddress(new Uri(jsonURI)); 
     ServiceEndpoint jsonEndpoint = new ServiceEndpoint(description, webhttpbinding, jsonEndpointAddress); 
     jsonEndpoint.Behaviors.Add(new WebHttpBehavior()); 


     // Create WSHTTP Binding   
     WSHttpBinding wsHttpBinding = new WSHttpBinding(); 
     string soapURI = internalEndpointAddress + "/soap"; 
     EndpointAddress soapEndpointAddress = new EndpointAddress(new Uri(soapURI)); 
     ServiceEndpoint soapEndpoint = new ServiceEndpoint(description, wsHttpBinding, soapEndpointAddress); 



     container.AddFacility<WcfFacility>(f => f.CloseTimeout = TimeSpan.Zero) 
       .Register(Component.For<IDiagnosticService>() 
        .ImplementedBy<DiagnosticService>() 
        .Named("DiagnosticService") 
        .LifestyleTransient() 
        .AsWcfService(new DefaultServiceModel() 
            .Hosted() 
            .AddEndpoints(WcfEndpoint.FromEndpoint(jsonEndpoint)) 
            .AddEndpoints(WcfEndpoint.FromEndpoint(soapEndpoint)) 
            .PublishMetadata(o => o.EnableHttpGet())));