mime4j errors with reasteasy
ziggy25 Feb 18, 2012 5:08 PMI have a Spring MVC and Resteasy based REST service that i need to test by sending a multipart/mixed request.
The service is coded as follows:
@POST
@Path("/mixedMimeText")
@Consumes("multipart/mixed")
@ResponseStatus(HttpStatus.OK)
public String createMime(@Context ServletContext servletContext, MultipartInput input) throws Exception, IOException {
logger.info("Processing /mixedMimeText");
for(InputPart p : input.getParts()){
logger.info("Headers : " + p.getHeaders());
logger.info("MediaType : " + p.getMediaType());
logger.info("Body : " + p.getBodyAsString());
logger.info("--------------------------------------------------- ");
}
return "TEST";
}
I am using the following file to send as the multipart mime content
--ABC123Boundary
Content-Type: text/xml
<?xml version="1.0" ?>
<request>
<account-id>XXXX-XXXX-XXXX-XXXX</account-id>
<reference>12345</reference>
<app-name>XXXXXXXXX</app-name>
<information>
<calling-party>
<name>Joe Bloggs</name>
<identifier>441234567890</identifier>
</calling-party>
<called-party>
<name>John Smith</name>
<identifier>15551234567</identifier>
</called-party>
</information>
</request>
--ABC123Boundary
Content-Type: text/xml
UklGRkBAAABXQVZFZm10IBAAAAAHAAEAQB8AAEAfAAABAAgAZmFjdAQAAAAPQ
AAAZGF0YRBAAABn5///////////////5///Z+fn///n////////5////////2f//2f//+f//+f////n/
///////52f//////2f//////2f/////5////////+f/////Z+f///////////////9n//9nZ/9n////5+f///9
<snip>
//+f//////2f/////////5//n//////////9n
--ABC123Boundary--
I am sending the request using the curl client with the following command:
curl -X POST http://localhost:8080/MyRestServices/restportal/services/mixedMimeText -i -H "Content-Type: multipart/mixed; boundary="--ABC123Boundary" -T myfile.txt
The request does get to the service but all i see on the JBOSS terminal is that it produces the following error which does not really make sense. There is no stack trace or any other errors.
21:48:37,174 WARN [org.apache.james.mime4j.parser.MimeEntity] (http--127.0.0.1-8080-1) Unexpected end of headers detected. Higher level boundary detected or EOF reached.
21:48:37,175 WARN [org.apache.james.mime4j.parser.MimeEntity] (http--127.0.0.1-8080-1) Invalid header encountered
21:48:37,176 WARN [org.apache.james.mime4j.parser.MimeEntity] (http--127.0.0.1-8080-1) Body part ended prematurely. Boundary detected in header or EOF reached.
It sounds like there is something wrong with the content but i am not quite sure.