public boolean handleMessage(MessageContext arg0) {
SOAPMessageContext ct = (SOAPMessageContext) arg0;
boolean isRequestFlag
= (Boolean) arg0
.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
SOAPMessage msg = ct.getMessage();
if (!isRequestFlag) {
try {
Object obj
= ct.
get("Attachments");
Attachments atts = (Attachments) obj;
List list
= atts.
getContentIDList();
for (int i = 1; i < list.size(); i++) {
DataHandler d = atts.getDataHandler(id);
byte[] arr = new byte[1024];
int n = 0;
while ((n = zip.read(arr)) > 0) {
out.write(arr, 0, n);
}
Document doc
= DocumentBuilderFactory.
newInstance()
.newDocumentBuilder()
SOAPBody body = msg.getSOAPBody();
Node port = body.getChildNodes().item(0);
port.appendChild(doc.getFirstChild().getFirstChild());
}
} catch (SOAPException e) {
e.printStackTrace();
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
return true;
}//源代码片段来自云代码http://yuncode.net