The answer is the log tracing the WCF.
My service is:
[Operationcontract (name = "add")] [webinvoke (uritemplate = "test/", method = "Post", responseformat = webmessageformat. JSON, requestformat = webmessageformat. JSON)] public int add (number N1) {res = convert. toint32 (n1.number1) + convert. toint32 (n1.number2); Return res ;}
Data are ..
[Serializable] public class number {public int number1 {Get; set;} public int number2 {Get; Set ;}}
When I call from Fiddler its return 'HTTP/1.1 400 bad request'
My fiddler request header is:
User-AGENT: fiddlerhost: localhost:4217Content-Type: Application/JSON; charset = UTF-8
And Request body is:
{"Number1":"7","Number2":"7"}
And response header is:
HTTP/1.1 400Bad requestserver: ASP. NET development server/10.0.0.0Date: Sun,14Aug2011 18:10:21Gctx-ASPnet-version:4.0.30319Content-Length:5450Cache-Control:PrivateContent-Type: text/Htmlconnection: Close
The way you'll find out the issue with your code is to enable tracing on the server, and it will have an exception explaining the problem. I wrote a simple test with your code, and it had a similar error (400), and the traces had the following error:
The data contract type'Wcfforums. stackoverflow_7058942 + number'Cannot bedeserialized because the required data members'& Lt; number1 & gt; K _ backingfield,& Lt; number2 & gt; K _ backingfield'Were not found.
See also
Http://msdn.microsoft.com/en-us/library/ms733025.aspx