WCF には 2 つの個別のメッセージ コントラクトがあります。
[MessageContract(WrapperName = "GetFooRequest", WrapperNamespace = "http://whatever.services.schema")]
public class GetFooRequest
{
[MessageHeader]
public int ResponseType { get; set; }
[MessageBodyMember(Order = 1)]
public string FirstName { get; set; }
[MessageBodyMember(Order = 1)]
public string LastName { get; set; }
}
[MessageContract(WrapperName = "GetBarRequest", WrapperNamespace = "http://whatever.services.schema")]
public class GetBarRequest
{
[MessageHeader]
public int ResponseType { get; set; }
[MessageBodyMember(Order = 1)]
public string FirstName { get; set; }
[MessageBodyMember(Order = 1)]
public string LastName { get; set; }
}
これは正常に動作しますが、GetBarRequest で MessageHeader のタイプを変更するとすぐに、サービスは動作しなくなります。
[MessageHeader]
public string ResponseType { get; set; }
現在、GetFooRequest と GetBarRequest の両方に ResponseType という MessageHeader がありますが、タイプが異なります。サービスが機能しなくなりました。2 つの完全に異なるメッセージ コントラクトで同じ名前/異なる型の MessageHeader を使用できないのはなぜですか?
私が得るエラーはかなり不可解です:
Error: Cannot obtain Metadata from http://localhost:42575/Services/Test/TestService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:42575/Services/Test/TestService.svc Metadata contains a reference that cannot be resolved: 'http://localhost:42575/Services/Test/TestService.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:42575/Services/Test/TestService.svc. The client and service bindings may be mismatched. The remote server returned an error: (415) Unsupported Media Type.HTTP GET Error URI: http://localhost:42575/Services/Test/TestService.svc There was an error downloading 'http://localhost:42575/Services/Test/TestService.svc'. The underlying connection was closed: The connection was closed unexpectedly.