I have been pulling my hair out trying to get a working example of sending
attachments from the client to the server with MTOM. I can send a single
file using a data handler argument, however what I'd like to do is use the
attachments map to send multiple files. This just doesn't seem to work -
the client doesn't send the attachments.
Here is my service:
@MTOM
@WebService
public class FileService
{
@Resource()
WebServiceContext wsContext;
@WebMethod
public void sayHelloWorldFrom( String from )
{
String result = "Hello, world, from " + from;
MessageContext context = wsContext.getMessageContext();
Map attachments = (Map)context.get(
MessageContext.INBOUND_MESSAGE_ATTACHMENTS );
System.out.println( "attachments = " + attachments );
}
}
And the client:
FileService fileService = new FileServiceService().getFileServicePort(new
MTOMFeature(1));
FileDataSource source = new FileDataSource( "testfile.dat" );
DataHandler dh = new DataHandler( source );
Map<String,Object> requestContext = ( (BindingProvider)fileService
).getRequestContext();
Map attachments = (Map)requestContext.get(
MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS );
if ( attachments == null )
{
attachments = new HashMap();
requestContext.put( MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS, attachments
);
}
// Is the map by mime type or file name?
attachments.put( "file1", dh );
fileService.sayHelloWorldFrom( "Pat" );
Any thoughts would be appreciated.
thanks,
Pat
--
View this message in context:
http://www.nabble.com/Example-of-client-%3Eserver-attachments--tp23906735p23906735.html
Sent from the cxf-user mailing list archive at Nabble.com.