Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
671 views
in Technique[技术] by (71.8m points)

web services - How can I control the name of generic WCF return types?

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...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...