This week's book giveaway is in the Testing forum.
We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!
See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

REST Service - How to send XML Request from Chrome or Intellij's REST Explorer?

Mike London
Ranch Hand
Posts: 1213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a basic question, perhaps I'm confused, but I have a simple JAX-RS application and we want to send an XML Request, like you would do in Chrome or from any REST explorer.

I have a test "client" program running that works, but it has commands like this:

Response response ="http://localhost:8080/services/customers")

(using the project's jetty server.)

But, I want to call the service directly from the REST explorer.

So, if you have an XML Request like the one in the JAX-RS 2.0 Book (ch 3), how would you "POST" it to the JAX-RS Service?

Here's the XML Request from the book, from the client code class:

String xml = "<customer>"
+ "<first-name>Bill</first-name>"
+ "<last-name>Burke</last-name>"
+ "<street>256 Clarendon Street</street>"
+ "<city>Boston</city>"
+ "<state>MA</state>"
+ "<zip>02115</zip>"
+ "<country>USA</country>"
+ "</customer>";

So, said another way, I just want to call the REST web service with a REST client and pass the XML Request for a POST.

I took the commented Customer string above and used this as a test to POST as the customer XML:


<street>256 Clarendon Street</street>


Then, in Intellij's REST Explorer, I have the path to the customer (and the web apps name), like this:


(this URL path is for the deployed service in Tomcat.)

I put the Customer XML from above in as the Request and tried to do a POST.

But I get an "Empty Response" return (but not an error).

The application class has this setup:

public class ShoppingApplication extends Application {
private Set<Object> singletons = new HashSet<Object>();


Here's the actual code in the service class:

public class CustomerResource
public Response createCustomer(InputStream is)
Customer customer = readCustomer(is);
customerDB.put(customer.getId(), customer);
System.out.println("Created customer " + customer.getId());
return Response.created(URI.create("/customers/" + customer.getId())).build() ;


For simplicity, this example uses a ConncurrentHashMap as a "database".


Do I need to wrap the Request XML with some tag to help things along or am I totally confused?

Thanks very much in advance.

- mike
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic