I'm building a web service which uses MessageContracts, because I want to add custom fields to my SOAP header. In a previous topic, I learned that a composite response has to be wrapped. For this purpose, I devised a generic ResponseWrapper class.
[MessageContract(WrapperNamespace = "http://mynamespace.com",
WrapperName="WrapperOf{0}")]
public class ResponseWrapper<T>
{
[MessageBodyMember(Namespace = "http://mynamespace.com")]
public T Response
{
get;
set;
}
}
I made a ServiceResult base class, defined as follows:
[MessageContract(WrapperNamespace = "http://mynamespace.com")]
public class ServiceResult
{
[MessageBodyMember]
public bool Status
{
get;
set;
}
[MessageBodyMember]
public string Message
{
get;
set;
}
[MessageBodyMember]
public string Description
{
get;
set;
}
}
To be able to include the request context in the response, I use a derived class of ServiceResult, which uses generics:
[MessageContract(WrapperNamespace = "http://mynamespace.com",
WrapperName = "ServiceResultOf{0}")]
public class ServiceResult<TRequest> : ServiceResult
{
[MessageBodyMember]
public TRequest Request
{
get;
set;
}
}
This is used in the following way
[OperationContract()]
ResponseWrapper<ServiceResult<HCCertificateRequest>> OrderHealthCertificate(RequestContext<HCCertificateRequest> context);
I expected my client code to be generated as
ServiceResultOfHCCertificateRequest OrderHealthCertificate(RequestContextOfHCCertificateRequest context);
Instead, I get the following:
ServiceResultOfHCCertificateRequestzSOTD_SSj OrderHealthCertificate(CompType1 c1, CompType2 c2, HCCertificateRequest context);
CompType1
and CompType2
are properties of the RequestContext
class. The problem is that a hash is added to the end of ServiceResultOfHCCertificateRequestzSOTD_SSj
. How do I need define my generic return types in order for the client type to be generated as expected (without the hash)?