What if you encounter a problem when consume your WCF Service? How to diagnostic it?

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.