if (boundary == null || boundary.equals("")) {
throw new WebServiceException("MIME boundary parameter not found" + contentType);
}
MIMEMessage message = new MIMEMessage(input, boundary);
MIMEPart jsonPart = null;
for(MIMEPart mimeAttach : message.getAttachments()){
if(mimeAttach.getContentType().equalsIgnoreCase(JSONContentType.JSON_MIME_TYPE)) {
jsonPart = mimeAttach;
break;
} else {
List<String> contentDisposition = mimeAttach.getHeader(JSONCodec.CONTENT_DISPOSITION_HEADER);
if(contentDisposition != null && contentDisposition.size() > 0){
try {
ContentDisposition disp = new ContentDisposition(contentDisposition.get(0));
if(disp.getParameter("name") != null && disp.getParameter("name").equals(JSON_PARAM_NAME)){
jsonPart = mimeAttach;
break;
}
} catch (ParseException e) {}
}
}
}
if(jsonPart == null){
throw new RuntimeException(String.format("There is no request JSON found in multipart mime. Your JSON input http \"parameter\"" +
" must be named as \"%s\" or pass %s: <Your json param name>. In alternate case body part content type should be %s " +
" json content as mime part body.", JSONCodec.XJSONPARAM_DEFAULT, JSONCodec.XJSONPARAM_HEADER, JSONContentType.JSON_MIME_TYPE));
}
List<MIMEPart> attachments = message.getAttachments();
/*
* Remove JSON part from attachment list. JSON part reseved for codec. and handled by JSONDecoder.
*
*/
attachments.remove(jsonPart);
/*
* Put attachemnts into invoke properties of packet.
*/
this.packet.invocationProperties.put(JSONCodec.MIME_ATTACHMENTS,attachments);
/*
* Decode message
*/
com.sun.xml.ws.api.message.Message wsMessage = new JSONDecoder(this.codec,jsonPart.readOnce(),packet).getWSMessage();
/*
* Remove attachment. Else same packet object used in response. It leads attachment fall back in response.
*/
this.packet.invocationProperties.remove(JSONCodec.MIME_ATTACHMENTS);
/*