views:

786

answers:

3

I've got a WCF Web Service method whose prototype is:

[OperationContract]
Response<List<Customer>> GetCustomers();

When I add the service reference to a client, Visual Studio (2005) creates a type called "ResponseOfArrayOfCustomerrleXg3IC" that is a wrapper for "Response<List<Customer>>". Is there any way I can control the wrapper name? ResponseOfArrayOfCustomerrleXg3IC doesn't sound very appealing...

A: 

Yes. The OperationContractAttribute takes a parameter called Name. You could specify it like this:

[OperationContract(Name = "NameGoesHere")]
Response<List<Customer>> GetCustomers();
Micah
I don't want to specify the name of the operation, I want to specify the name of the DataContract. The problem is the DataContract I'm using is generic.
ilitirit
+1  A: 

Please try this:

[OperationContract]
[return: MessageParameter(Name="YOURNAME")]
Response<List<Customer>> GetCustomers();
aogan
That doesn't work either
ilitirit
+4  A: 

You can define your own name in the DataContract attribute like this:

[DataContract(Name = "ResponseOf{0}")]
public class Response<T>

Note that in your example the {0} will be replaced and your proxy reference type will be ResponseOfArrayOfCustomer.

More info here: WCF: Serialization and Generics

Panos