I have a WCF service that is returning my json surrounded by xml string.

example return

<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">[{...},{...}]</string>

web service function below

        [WebInvoke(UriTemplate = "/test",  Method = "GET")]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string test() 
        {
            return db.Instance.test();
        }

however if I change the return type to message and create text response it works fine.

        [WebInvoke(UriTemplate = "/test",  Method = "GET")]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public Message test() 
        {
            return WebOperationContext.Current
                   .CreateTextResponse(db.Instance.test());
        }

while obviously the Message return type works and is valid I do not understand why my current implementation does not work.

0 Answers