I have two separate message contracts in WCF:
[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; }
}
This works fine, but as soon as I change the type of the MessageHeader on GetBarRequest, the service no longer works:
[MessageHeader]
public string ResponseType { get; set; }
Now I have a MessageHeader called ResponseType in both GetFooRequest and GetBarRequest, but they have different types. The service no longer works. Why can I not have a MessageHeader with the same name / different type on two completely different Message Contracts?
The error I get is pretty cryptic:
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.
Message contract displayed as primitive type on wsdl, so
GetBarRequest
andGetFooRequest
looks followingWCF does not validate schema by name and type, only name, so type is changed name is the same, following error is occurred