この質問は重複していませんので、注意してお読みください。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クラスにプライベートプロパティがある理由を教えてください。彼らは公開されるべきです。 –