An Easy Way to Test HTTP Requests During Development
Web and web services developers often need to send HTTP requests – whether for testing APIs, testing REST and SOAP web services, or managing web sites.
XMLSpy makes it easy to send and receive HTTP requests directly in the XML and JSON editor during development with its HTTP Window and WADL/WSDL Import Wizard, a great time-saving tool for debugging web services.
Test HTTP Requests
The HTTP protocol defines how files (text, images, etc.) are transmitted over the Internet. Every web server runs a program (known as a daemon) that continuously waits for HTTP requests and handles each as it arrives.
For example, when you visit a website’s home page, your browser sends an HTTP command to the website’s web server that requests the download of the home page; the server’s HTTP daemon receives the request and sends the requested page. It’s important to note that the HTTP protocol is stateless, which means that each HTTP command is carried out independently, without any reference to previous or following commands — and this can make testing and debugging a challenge.
To assist developers with this, the HTTP testing window in XMLSpy guides you through the process of creating and sending an HTTP request to a web server. Then, you can receive, check, and troubleshoot the response.
A request is defined in the left-hand pane of the window and may consist of:
- The HTTP method of the request (GET, PUT, POST, etc.) and the target URL
- HTTP headers of the request
- Connection settings, e.g., time outs and security options
- For POST and PUT methods, the HTTP message body
Nine separate tabs in the HTTP window allow you to store and test multiple messages and switch between them as needed.
When the request is defined, press Send to send it to the web server. You can analyze the response immediately in the right-hand pane, which displays the body (shown above) and header info:
Importing a WADL or WSDL Request
You can also initiate a test by importing a request from a WADL (Web Application Description Language) file, which provides a machine-readable description of an HTTP-based application, or a WSDL document describing SOAP web service endpoints.
The XMLSpy HTTP window includes a WADL / WSDL import wizard that walks you through opening a file, selecting a request for testing, and modifying any editable parameters of the request.
Then it imports the request into the HTTP window so you can send it and review the response.
Debugging a REST API
Let’s take a look at a real-world example, using the HTTP window to test the response from a web API. The City of Chicago Data Portal is a publicly available REST API that provides interesting data about anything from building permits to municipal budgets to numbers of asthma hospitalizations in the city.
For this example, we’ll delve into the traffic category and focus on a dataset of red light violations. I can enter the URL in the HTTP window to return the entire dataset, and ending the request with .xml or .json specifies the format of the returned data. I’ve chosen XML for this run, but of course XMLSpy has built-in tools for working with both formats. You can see the result returned by the HTTP window below.
We can review the data in the results pane or click Create New Document to open the document in XMLSpy text or grid view, where it’s easier to scroll through and spot check the data returned by the API.
With the data in a file we can even use XQuery to zero in further. Let’s take a look at camera locations with greater than 20 violations.
Now, let’s grab the data again, but this time in JSON format.
Here it is opened in text view…
And you can also view the JSON in XMLSpy’s unique JSON grid view for a graphical representation. JSON Grid makes it much easier to scan and understand the returned data, especially when dealing with large data sets like this. The JSON editor also includes built in support for filtering data with XQuery, as shown below. I’ve filtered the data to show those records with intersections that include Halsted Street.
The HTTP Window, along with built-in viewing and editing tools, make XMLSpy a great tool for testing and debugging APIs, Web services, and other HTTP applications.
Download a free trial of XMLSpy to try the HTTP window.