views:

637

answers:

2

[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 :(

A: 

When you add or configure your service reference on the client side, there's a checkbox which mentions something about generating Async methods.

If it's checked, try unchecking it and see if this removes the autogenerated request/response methods.

I had a similar problem over a year ago so solution is a little hazy.

vidalsasoon
No, it's not checked :(
Marcel Popescu
A: 

Do you have the same problem if you use svcutil.exe to generate your proxy classes? If so, then this is not a VS2008 problem.

This problem doesn't surprise me. Generics in .NET are not macros. You're expecting the WSDL generator to dig out the specific type used as an actual type parameter to your instantiation of the generic service contract. I think that's a non trivial thing to ask for.

I recommend you create a simple version of this problem and report it on http://connect.microsoft.com/visualstudio/. Do a quick search, first, to see if it has already been reported. When you've reported it, post the URL of the report as an edit to your question so that others can vote on it.

John Saunders
I figured out a way, I'm editing my initial post... I have no idea *why* it works, though :)
Marcel Popescu