• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem Passing XML and text as POST parameters from RESTClient to Spring MVC Application

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In my current application i am required to pass two parameters to the REStful Spring MVC application. One parameter is an id and the other is an xml passed as a string.



There is a complex operation that needs to be performed before the spring container passes the parameter to the controller method. Therefore i am using a Custom HttpMessageConverter to parse the obtained XML into a Template object.

Here is the part of the Custom Converter that i am using



To Test this i am using FireFox Rest Client (see attatchment)

The problem is that i am just recieving <?xml version from http request where as the typeid parameter is perfectly mapped.

All suggestions are welcome.
xmlPostParamIssue.png
[Thumbnail for xmlPostParamIssue.png]
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem here is that you have spaces in your parameter value.
How're you passing these request params? Using some form in a JSP? Post the JSP code where you're submitting the form.

You need to encode the value before sending.
If JSP, this post might help.
 
shukla raghav
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Surendra, Actually i am not using any JSP as of now. Currently we are testing our REST API using FireFox Rest Client. yes it has got something to do with the way parameter values are passed although it seems to me that the = sign in prolog <?xml version="1.0" is taken as another assignment operator. But quite possible that replacing spaces with %20C or whatever HTML entity for space may do the trick.
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to properly escape the xml string and pass it. You may find many formatters online.
Try with a small string first to see if you're able to receive it right on the server side.
 
shukla raghav
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i used apache commons codec for encoding and decoding the xml. escaping will not work here. Yes the encoding did the trick.

 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic