I am trying to find info on how to go about modifying the name of the object returned from a wcf service, in json format, to a web client via an ajax call, instead of using the default wrapper. I have searched for related articles with no luck. It seems the default wrapper name for the result will be MethodNameResult and I would like it to be GenericResponse from multiple methods.
My contract:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[WcfSerialization::DataContract(Name = "MyServiceResponse")]
public class MyServiceResponse : object
{
    public MyServiceResponse()
    {            
    }
    [WcfSerialization::DataMember(Name = "Success", IsRequired = true, Order = 0)]
    public bool Success { get; set; }
    [WcfSerialization::DataMember(Name = "ErrorMessage", IsRequired = true, Order = 1)]
    public string ErrorMessage { get; set; }  
}
My interface:
    [OperationContract()]        
    [WebInvoke(Method = "POST", 
        UriTemplate = "MyMethod", 
        BodyStyle = WebMessageBodyStyle.Wrapped, 
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat=WebMessageFormat.Json
    )]
    MyServiceResponse MyMethod(MyRequest requestData); 
    [OperationContract()]        
    [WebInvoke(Method = "POST", 
        UriTemplate = "MyMethod2", 
        BodyStyle = WebMessageBodyStyle.Wrapped, 
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat=WebMessageFormat.Json
    )]
    MyServiceResponse MyMethod2(MyRequest requestData); 
I would expect since I have decorated the method result's data contract with a name "MyServiceResult" then that would be the name of the resulting json object, instead I am getting a different name for each method request. For example, instead of:
{"MyServiceResponse":{"Success":true,"ErrorMessage":""}}
Over the wire I am getting:
{"Method1Result":{"Success":true,"ErrorMessage":""}}
and
{"Method2Result":{"Success":true,"ErrorMessage":""}}
This is preventing the client from making a generic inspection of the result as would be the case in
success: function (returnData, textStatus, xhr) {
            result.success = returnData.MyServiceResponse.Success;
            result.errorMessage = returnData.errorMessage;
},
Thanks
 
     
     
    