Forum Discussion

leadfoot77's avatar
11 years ago

multipart/form-data with JSON component - BUG?

I have a simple web service:


@RequestMapping(value="/jsTest4", method=RequestMethod.POST)
public @ResponseBody String jsTest4(@RequestPart UploadMessage message, @RequestPart MultipartFile file) {
String filename = file.getOriginalFilename();
long size = file.getSize();

return "Got \"" + message.getDescription() + "\" file = \"" + filename + "\"(" + size + ")";
}


that I am trying to test with SoapUI but failing. I create a new request, set to POST, select multipart/form-data for the media type, type my json into the text box below the media type, and then use the attachments tab to attach a file. The problem is that it sets the media type for the first part of the multipart message to multipart/form-data instead of application/json like it should. Am I doing something wrong or is this just a bug in SoapUI?

From the httplog:


Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "POST /uploadTest/jsTest4 HTTP/1.1[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Accept-Encoding: gzip,deflate[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Content-Type: multipart/form-data; boundary="----=_Part_32_736622159.1391022283032"[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "MIME-Version: 1.0[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Content-Length: 37812[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Host: kmrlavauploadtest.appspot.com[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Connection: Keep-Alive[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "------=_Part_32_736622159.1391022283032"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Content-Type: multipart/form-data"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Content-Transfer-Encoding: 8bit"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "{"description":"testing multipart/form","email":"test@fake.com","versionNumber":"1.1.1.1","checksum":"3891784721"}"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "------=_Part_32_736622159.1391022283032"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Content-Type: image/x-png; name=don20.png"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Content-Transfer-Encoding: binary"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "Content-Disposition: form-data; name="don20.png"; filename="don20.png""
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"

...... SNIP file byte data.............


Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "------=_Part_32_736622159.1391022283032--"
Wed Jan 29 14:04:43 EST 2014:DEBUG:>> "[\r][\n]"



Please let me know if I'm doing something wrong or if there is a way to workaround this issue. Thanks!