0

I am writing restful web services and everything is fine, my web services are takes input as XML and producing output as XML. For the client testing of web service, I am using the Firefox Poster extension. It is working fine but a few of my web services take input as a JSON object and produce output as a JSON object. My question is how to pass a JSON object to poster instead of XML. Or maybe a different extension can be used for client testing of restful web services producing JSON objects.

For example, one of my web services looks like this:

public String authenticateUser(@FormParam("userName") String userName, @FormParam("password") String password)
{

//related stuffs

}

How to test authenticateUser web service using Poster extension or something else?

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
subodh
  • 6,136
  • 12
  • 51
  • 73

1 Answers1

0

Setting "Content Type:" field (on "Content to Send" tab) to application/json should help.

You can also specify "Accept" parameter on Headers tab with application/json value to inform service that you expect output in JSON format.

Ivan Korneliuk
  • 349
  • 1
  • 4
  • Thanks Ivan, But how can i pass the parameter of the web service, i have two parameters such as "userName" and "password" in poster plugin. – subodh Jun 14 '12 at 05:24
  • As far as I understand, `@FormParam` expects request body to be of "application/x-www-form-urlencoded" type (an HTML Form). To simulate an HTML Form in Poster, you can specify parameters on the "Parameters" tab. When you click back to "Content to Send" tab, you'll see that parameters are converted to properly encoded data. And Content-Type is changed to "application/x-www-form-urlencoded". Hope this helps. – Ivan Korneliuk Jun 14 '12 at 08:41