[Edit] I figured out a way to make it work, comments in the code.
I have dozens, and will soon have hundreds of workflows with the following contract:
[ServiceContract(Namespace = "http://schema.company.com/messages/")]
public interface IBasicContract<TRequest, TResponse>
where TRequest : class
where TResponse : class
{
[OperationContract]
[XmlSerializerFormat]
[ServiceKnownType(typeof(Aggregate))]
TResponse GetReport(TRequest inquiry);
[OperationContract]
[XmlSerializerFormat]
[ServiceKnownType(typeof(Aggregate))]
string GetRawReport(string guid);
[OperationContract]
[XmlSerializerFormat]
[ServiceKnownType(typeof(Aggregate))]
TResponse GetArchiveReport(string guid);
}
I have created a common implementation:
// v added
[ServiceBehavior(Namespace = "http://schema.company.com/messages/")]
// ^ added
public abstract class BasicWorkflowSvc<TRequest, TResponse, TWorkflow> : IBasicContract<TRequest, TResponse>
where TRequest : class
where TResponse : class
where TWorkflow : class
{
//...
}
The actual implementation looks like this:
[XmlSerializerFormat]
// v changed
[ServiceContract(Namespace = "http://services.company.com/messages/")]
// ^ changed
public interface IActualProductSvc : IBasicContract<ActualProductRq_Type, ActualProductRs_Type>
{
}
[ServiceBehavior(Namespace = "http://services.company.com/ActualProduct/v1.0")]
// v added
[MessageContract(WrapperNamespace = "http://services.company.com/ActualProduct/v1.0")]
// ^ added
public class ActualProductSvc : BasicWorkflowSvc<ActualProductRq_Type, ActualProductRs_Type, EF>, IActualProductSvc
{
//...
}
My problem is this: when I add a Service Reference to this project into another project, the generated code has additional (and useless) Request and Response types:
[GeneratedCode("System.ServiceModel", "3.0.0.0")]
[ServiceContract(Namespace = "http://services.company.com/ActualProduct/v1.0", ConfigurationName = "ActualProduct.IActualProductSvc")]
public interface IActualProductSvc
{
// CODEGEN: Generating message contract since the wrapper namespace (http://schema.company.com/messages/) of message GetReportRequest does not match the default value (http://services.company.com/ActualProduct/v1.0)
[OperationContract(Action = "http://schema.company.com/messages/IBasicContractOf_ActualProductRq_Type_ActualProductRs_Type/GetReport",
ReplyAction = "http://schema.company.com/messages/IBasicContractOf_ActualProductRq_Type_ActualProductRs_Type/GetReportResponse")]
[XmlSerializerFormat()]
[ServiceKnownType(typeof (Aggregate))]
GetReportResponse GetReport(GetReportRequest request);
// CODEGEN: Generating message contract since the wrapper namespace (http://schema.company.com/messages/) of message GetRawReportRequest does not match the default value (http://services.company.com/ActualProduct/v1.0)
[OperationContract(
Action = "http://schema.company.com/messages/IBasicContractOf_ActualProductRq_Type_ActualProductRs_Type/GetRawReport",
ReplyAction = "http://schema.company.com/messages/IBasicContractOf_ActualProductRq_Type_ActualProductRs_Type/GetRawReportResponse")]
[XmlSerializerFormat()]
[ServiceKnownType(typeof (Aggregate))]
GetRawReportResponse GetRawReport(GetRawReportRequest request);
// CODEGEN: Generating message contract since the wrapper namespace (http://schema.company.com/messages/) of message GetArchiveReportRequest does not match the default value (http://services.company.com/ActualProduct/v1.0)
[OperationContract(
Action = "http://schema.company.com/messages/IBasicContractOf_ActualProductRq_Type_ActualProductRs_Type/GetArchiveReport",
ReplyAction =
"http://schema.company.com/messages/IBasicContractOf_ActualProductRq_Type_ActualProductRs_Type/GetArchiveReportResponse")]
[XmlSerializerFormat()]
[ServiceKnownType(typeof (Aggregate))]
GetArchiveReportResponse GetArchiveReport(GetArchiveReportRequest request);
}
... with a bunch of wrappers:
[DebuggerStepThrough()]
[GeneratedCode("System.ServiceModel", "3.0.0.0")]
[MessageContract(WrapperName = "GetReport", WrapperNamespace = "http://schema.company.com/messages/", IsWrapped = true)]
public partial class GetReportRequest
{
[MessageBodyMember(Namespace = "http://schema.company.com/messages/", Order = 0)]
public ActualProductRq_Type inquiry;
public GetReportRequest()
{
}
public GetReportRequest(ActualProductRq_Type inquiry)
{
this.inquiry = inquiry;
}
}
Is there a way, short of deleting them by hand, to make those wrappers NOT be generated? The reason I'm asking is that they were not generated before I tried to extract the common contract from all the workflows - there was no common interface with a different namespace - and the people who are using those workflows are complaining about having to update all the references and then manually delete a lot of stuff from the Reference.cs files.
I hate the WSDL importer in Visual Studio :(