이 질문은 중복되지 않으므로 신중하게 읽으십시오.HTTP 응답을 수신하는 동안 WCF 오류가 발생했습니다.
같은 도메인의 다른 컴퓨터에 WCF 서비스와 클라이언트가 있습니다. WCF 서비스는 다음과 같은 운영 계약을 체결하고 :
[ServiceContract]
public interface IPatchService
{
[OperationContract]
List<PatchUpdateDTO> SearchForUpdates();
[OperationContract]
string InstallUpdates();
}
PatchUpdateDTO
클래스 :
[Serializable]
[DataContract]
public class PatchUpdateDTO
{
[DataMember]
private string UpdateId { get; }
[DataMember]
private string Title { get; }
[DataMember]
private string Description { get; }
}
요청 리스너에 대한 서비스 코드 : 내 클라이언트에 서비스 참조를 추가 한
Uri baseAddress = new Uri("http://localhost:8000/PatchManagementService");
_selfHost = new ServiceHost(typeof(PatchService), baseAddress);
try
{
_selfHost.AddServiceEndpoint(typeof(IPatchService), new WSHttpBinding(), "PatchService");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
_selfHost.Description.Behaviors.Add(smb);
_selfHost.Open();
}
catch (CommunicationException ce)
{
...
}
신청.
클라이언트 코드 :
public class AgentCommunicationWCFProvider : IAgentComminicationProvider
{
private readonly PatchServiceClient _patchManagementService;
public AgentCommunicationWCFProvider()
{
_patchManagementService = new PatchServiceClient();
}
public string InstallUpdates()
{
return _patchManagementService.InstallUpdates();
}
public List<PatchUpdateDTO> SearchForUpdates()
{
return _patchManagementService.SearchForUpdates();
}
}
클라이언트 구성 :
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IPatchService" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://someIpAddress:8000/PatchManagementService/PatchService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPatchService"
contract="PatchManagementServiceReference.IPatchService" name="WSHttpBinding_IPatchService">
<identity>
<userPrincipalName value="****" />
</identity>
</endpoint>
</client>
</system.serviceModel>
이제 뭔가 이상한 일이 일어나고,() 메소드를 InstallUpdates를 사용할 때이 반환 문자열을 얻을 그것은 잘 작동하지만 SearchForUpdates() 메서드를 사용할 때 List<PatchUpdateDTO>
을 반환한다고 가정하면 다음 오류가 발생합니다.
추가 정보 : http : // someIpAddress : 8000/PatchManagementService/PatchService로 HTTP 응답을받는 동안 오류가 발생했습니다. HTTP 프로토콜을 사용하지 않는 서비스 엔드 포인트 바인딩 때문일 수 있습니다. 이는 서비스 요청이 종료되어 서버 에 의해 중단 된 HTTP 요청 컨텍스트로 인해 발생할 수도 있습니다. 자세한 내용은 서버 로그를 참조하십시오.
복잡한 개체에 문제가있는 이유는 무엇입니까?
[Serializable] 특성을 제거하고 다시 시도하십시오. 클래스와 속성에 DataContract 및 DataMember 특성이 이미 있으므로 상단에 [Serializable]을 사용하는 이유는 무엇입니까? InstallUpdates()는 WCF가 기본적으로 이해하는 문자열을 반환하기 때문에이 영역에 문제가있는 것 같습니다. –
PatchUpdateDTO 클래스에 개인 속성이있는 이유는 무엇입니까? 그들은 공개해야합니다. –