0

I have been working mostly on get requests and generally use RestClient to test any web service. Usually perform a GET for object.

Now I am attempting to do my first POST. For the GET requests, I have been passing a query string and parsing that way Now this web service is accepting many field. Ordin

  1. Does a POST always have to receive an object versus a string or even a query string? Probably a dumb question.

  2. When the object comes in since one of the fields is a byte array do I have to do anything special in terms of catching the field in a bytearray converter. Can the post accept multiple variables such as String, MultiPart

Will Hartung
  • 115,893
  • 19
  • 128
  • 203
Bill Lee
  • 121
  • 2
  • 4
  • 8

1 Answers1

0

Post receives whatever you want it to receive. It is completely setup through your method definition

void doRestPost(String foo)
void doAnotherRestPost(MyObject bar)

Here is an example that might help https://github.com/SpringSource/spring-mvc-showcase

Another post that is helpful: What is the difference between a HTTP-Get and HTTP-POST and why is HTTP-POST weaker in terms of security

According to http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html you should be find with a byte array.

Community
  • 1
  • 1
chrislovecnm
  • 2,549
  • 3
  • 20
  • 36
  • Thanks. One question. Can a image be passed in as part of a string like I was doing with byte arrays. – Bill Lee Aug 08 '11 at 18:08
  • you can convert a string to a byte array ... why do you want to? – chrislovecnm Aug 08 '11 at 18:09
  • One of the parameters coming is a binary image. I am not clear how the controller would receive this. Png File. Basically a file is submitted to the service along with other parameters. I take that file and email that to a list of recipients. – Bill Lee Aug 08 '11 at 18:11
  • http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch16s08.html ~ multi part upload ~ and please make my answer as the solution :) – chrislovecnm Aug 08 '11 at 18:12