How to change the name of an external object using WCF?

I use the WCS.svc class as follows:

[DataContract] public class FunInfo { ... } [OperationContract, WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)] public FunInfo SetInformation(int a, int b) { ... } 

When I get my JSON back, it looks like this:

 {"SetInformationResult":{ ... } } 

My question is: where did SetInformationResult come from, and can I manage its name without renaming my class? For example, for "d" to simulate what ScriptService does?

EDIT: for posterity, the relevant links I have found since: How can I manage the name of the WCF common return types?

+6
source share
1 answer

The name came from your operation name with the addition of β€œResult”. And you can rename it using the [MessageParameter] attribute when returning the method:

 [OperationContract, WebInvoke(...)] [return: MessageParameter(Name = "d")] public FunInfo SetInformation(int a, int b) { ... } 
+16
source

Source: https://habr.com/ru/post/911794/


All Articles