WCF 서비스 인 "LoadRefsImport"는 폴링 이중 방식 HTTP 서비스입니다.서비스가 모든 유형을 노출하지 않음
LoadRefsImport.svc :
namespace Code.Web.ProgressUpdate
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class LoadRefsImport : ProgressUpdateServiceBase, ICarrierImportService
{
public override TimeSpan UpdateFrequency
{
get { return TimeSpan.FromSeconds(1); }
}
public void ImportCarriers(string file, Country country)
{
StartOperation();
CarrierLogic.ProgressEventHandler += (o, e) => SendProgress(new Progress()
{
Message = e.Message,
PercentComplete = e.Progress
});
CarrierLogic.CarrierLoadedEventHandler += (o, e) => SendProgress(new Progress()
{
Message = "Loaded carrier",
PercentComplete = 0
});
CarrierLogic.ImportCarrier(file, country);
}
}
}
LoadRefsImport 마크 업 :
<%@ ServiceHost Language="C#" Debug="true" Service="iCode.Web.ProgressUpdate.LoadRefsImport" CodeBehind="LoadRefsImport.svc.cs" %>
ICarrierImportService :
namespace Code.Web.ProgressUpdate
{
[ServiceContract(CallbackContract = typeof(IProgressUpdateClient))]
public interface ICarrierImportService : IProgressUpdateService
{
[OperationContract(IsOneWay = true)]
void ImportCarriers(string file, Country country);
}
}
IProgressUpdateService :
namespace Code.Web.ProgressUpdate
{
[ServiceContract(CallbackContract = typeof(IProgressUpdateClient))]
public interface IProgressUpdateService
{
TimeSpan UpdateFrequency { get; }
[OperationContract(IsOneWay = true)]
void StartOperation();
}
}
IProgressUpdateClient : 내가의 Web.config에서 서비스를 설정 한
namespace Code.Web.ProgressUpdate
{
[ServiceContract]
public interface IProgressUpdateClient
{
[OperationContract(IsOneWay = true)]
void ReceiveProgress(Progress progress);
}
[DataContract]
public class Error
{
public enum Types
{
Error,
Warning,
Notice
}
[DataMember]
public Exception Exception { get; set; }
[DataMember]
public string Message { get; set; }
[DataMember]
public Types Type { get; set; }
}
[DataContract]
public class Progress
{
[DataMember]
public List<Error> Errors { get; set; }
[DataMember]
public string Message { get; set; }
[DataMember]
public float PercentComplete { get; set; }
}
}
다음과 같이
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement, System.ServiceModel.PollingDuplex, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
</extensions>
<behaviors>
<serviceBehaviors>
<behavior name="LoadRefsImportBehaviour">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<pollingDuplexHttpBinding />
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service behaviorConfiguration="LoadRefsImportBehaviour" name="Code.Web.ProgressUpdate.LoadRefsImport">
<endpoint binding="pollingDuplexHttpBinding"
contract="Code.Web.ProgressUpdate.ICarrierImportService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
나는 서비스를 볼 때 내 브라우저, 다 괜찮아요, 그리고 성공적으로 내 클라이언트 프로의 서비스 참조로 추가 할 수 있습니다 ject ("References types in referenced assembly"를 해제했을 때), 클라이언트 프로젝트에서 내 서비스를 사용하려고 할 때 서비스의 네임 스페이스에 노출 된 유일한 유형은 Error
, Progress
및 Exception
입니다. 내 서비스와 상호 작용할 수있는 수업이나 방법이 없습니다.
마크 업에서 모든 이름 참조가 올바른지 확인하기 위해 서비스 참조를 삭제하고 다시 작성하고 솔루션을 정리하고 다시 작성해 보았습니다.