Test your rest wcf Service through Fiddler

Source: Internet
Author: User

Fiddler is a powerful software. In actual development, it can help us track HTTP requests, record send requests and obtain the data of request results.
When VS2008 is used, IE6 is always used for browser debugging, and Fiddler is also normal. But I have always been used to using FireFox.
Fiddler cannot help record data (FireFox version: 4.0 ). I thought Fiddle could only be used in IE. I tried chrome and found that it could also be used.
This article briefly introduces how to use Fiddler for the REST Service (the specific example and the rest wcf Service with code described in the previous section: using the standard HTTP action.
First, let's talk about the Fiddler interface,

(Figure 1)
When testing the rest wcf Service, we need to select the Request Builder tab on the right, select Parse in the subitem on the tab, and then select the corresponding HTTP standard action, for example (GET \ POST \ DELETE \ PUT), enter the URI address in the address bar.

 

(Figure 2)

If different request types are defined in the contract results, for example, [WebInvoke (UriTemplate = "Student/{name}/{tel}", Method = "POST ", requestFormat = WebMessageFormat. json, ResponseFormat = WebMessageFormat. json)]
Enter the request header in JSON format, that is, Accept: application/json. Description:

 

(Figure 3)

View results:
1. TextView: The data displayed in text format is shown in Figure 6.
2. The returned results in Web format are shown as follows:

(Figure 4)
View the request header and return the HTTP header information:
Click Inspector on the right to view the request data and return data (because a URI may execute multiple HTTP requests, you must click the corresponding request on the left side to view the corresponding information)
For example, the request header and returned HTTP header are as follows:

(Figure 5)
If ResponseFormat is not specified, what format will be returned .?
Change the POST result definition:
[OperationContract]
[WebInvoke (
UriTemplate = "Student/{name}/{tel }"
, Method = "POST"
, RequestFormat = WebMessageFormat. Json
)]
String UpdateUser (string name, string tel );

After re-compilation, the re-call result is as follows:

(Figure 6)
Test Description: If the return format is not specified, it is returned in XML format by default.
Other operations are similar to the above, so this article will not go into details.

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.