I'm trying to implement SOAP attachments as described here
http://www.nabble.com/Soap-With-Attachments-t3567874.html and here
http://forums.java.net/jive/thread.jspa?threadID=14026&messageID=94882.
However, looking at the SOAP message with TCPMON, there are no
attachments generated. Below is my code and the generated SOAP. Can
someone point out what I'm doing wrong?
My function:
private static void uploadFile(GSWebService2 proxy, String
localFileName, String fileName) {
File sourceFile = new File("C:/"+localFileName);
DataHandler dh = new DataHandler(new
FileDataSource(sourceFile));
// Get a reference to the request context.
Map requestContext = ((BindingProvider)
proxy).getRequestContext();
// Get a reference to the attachments map.
Map<String, DataHandler> attachments = (Map<String,
DataHandler>)
requestContext.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
// If the attachments map is null, then create a new map
if (attachments == null) {
attachments = new HashMap<String, DataHandler>();
}
// Add the data handler to the list of outbound attachments.
attachments.put("multipart/*", dh);
// place it in the request context.
requestContext.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS,
attachments);
// Invoke the webservice call.
proxy.uploadFile(fileName);
}
The SOAP:
POST /Java6WS/GSWebService2 HTTP/1.1
SOAPAction: ""
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg,
*; q=.2, */*; q=.2
Content-Type:
multipart/related;type="application/xop+xml";boundary="uuid:74f1b1e2-95c
c-4226-b5c9-e2bfcc4cf4a2";start-info="text/xml"
User-Agent: Java/1.6.0
Host: localhost:8081
Connection: keep-alive
Transfer-Encoding: chunked
174
--uuid:74f1b1e2-95cc-4226-b5c9-e2bfcc4cf4a2
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary
<?xml version="1.0" ?><S:Envelope
xmlns:S="
http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:uploadF
ile
xmlns:ns2="
http://GroupService.cip.company.com/"><arg0>backgrounds.zip</
arg0></ns2:uploadFile></S:Body></S:Envelope>
2f
--uuid:74f1b1e2-95cc-4226-b5c9-e2bfcc4cf4a2--
0