tags:

views:

58

answers:

1

I have a really simple service that I'm messing about with defined by:

[OperationContract]
[WebInvoke(UriTemplate = "Review/{val}", RequestFormat = WebMessageFormat.Xml, Method = "POST", BodyStyle=WebMessageBodyStyle.Bare)]
void SubmitReview(string val, UserReview review);

UserReview is, at the moment, a class with no properties. All very basic. When I try and test this in Fiddler I get a bad request status (400) message.

I'm trying to call the service using the details:

POST http://127.0.0.1:85/Service.svc/Review/hello

Headers

User-Agent: Fiddler
Content-Type: application/xml
Host: 127.0.0.1:85
Content-Length: 25

Body

<UserReview></UserReview>

I would think i'm missing something fairly obvious. Any pointers?

A: 

By adding the XmlSerializerFormatAttribute to the method caused this to start working as expected

[OperationContract] 
[XmlSerializerFormat]
[WebInvoke(UriTemplate = "Review/{val}", RequestFormat = WebMessageFormat.Xml, Method = "POST", BodyStyle=WebMessageBodyStyle.Bare)] 
void SubmitReview(string val, UserReview review);
James Hay
My guess is that the DataContractSerializer requires some namespace goop to be able to know how to deserialize your object. Maybe the XMLSerializer is more forgiving. If you turn on the WCF tracing and use SvcTrace to look at the log you will get a better idea of what was going wrong. In fact if you are going to do any amount of WCF work I would learn to get very familiar with that tool.
Darrel Miller