I am trying to create java web service which returns image. I'm trying to do it with attachment, but I constantly get null pointer exception, after:

MessageContext context = MessageContext.getCurrentContext();
Message msg = context.getMessage();
AttachmentPart ap = msg.createAttachmentPart();

Can anybody please tell me what I am doing wrong?

Thnx in advanced