0

I'm going slidely mad over here, maybe someone can help me figure out what's going on. I have a WCF service exposing a function using webinvoke, like so:

[OperationContract]
        [WebInvoke(Method = "POST",
           BodyStyle = WebMessageBodyStyle.Wrapped,
           RequestFormat = WebMessageFormat.Json,
           ResponseFormat = WebMessageFormat.Json,
           UriTemplate = "registertokenpost"
        )]

        void RegisterDeviceTokenForYoumiePost(test token);

The datacontract for the test class looks like this:

[DataContract(Namespace="Zooma.Test", Name="test", IsReference=true)]
    public class test
    {
        string waarde;
        [DataMember(Name="waarde", Order=0)]
        public string Waarde
        {
            get { return waarde; }
            set { waarde = value; }
        }
    }

When sending the following json message to the service, { "test": { "waarde": "bla" } }

the trace log gives me errors (below). I have tried this with just a string instead of the datatype (void RegisterDeviceTokenForYoumiePost(string token); ) but i get the same error. All help is appreciated, can't figure it out. It looks like it's creating invalid xml from the json message, but i'm not doing any custom serialization here.

The formatter threw an exception while trying to deserialize the message: Error in
 deserializing body of request message for operation 'RegisterDeviceTokenForYoumiePost'. 
Unexpected end of file. **Following elements are not closed**: waarde, test, root.</Message><StackTrace>
   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, 
Object[] parameters)

1 Answer 1

0

The service expects { "token": { "waarde": "bla" } }, not { "test": { "waarde": "bla" } }

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.