Hi All,

 

Can anyone provide me with an example of a client reading an attachment by hand. My service does not expose DataHandlers in the method signature and just adds/receives the attachments by hand.

 

I have followed the Fear Of Attachments example in the implementation. All is working fine as far as the client sending up an attachment to the server. But when my client receives an attachment from the server and I try and read it the same way as the server using the following getAttachments(). The MessageContext is null. I am not sure what is wrong. Does the client not have access to a message context?

 

      private AttachmentPart[] getMessageAttachments() throws AxisFault

      {

            MessageContext msgContext = MessageContext.getCurrentContext();

            System.out.println("MESSAGE CONTEXT=" + msgContext);

            Message reqMsg = msgContext.getResponseMessage();

            Attachments messageAttachments = reqMsg.getAttachmentsImpl();

            if (messageAttachments == null)

            {

                  return new AttachmentPart[0];

            }

            int attachmentCount = messageAttachments.getAttachmentCount();

            AttachmentPart attachments[] = new AttachmentPart[attachmentCount];

            Iterator it = messageAttachments.getAttachments().iterator();

            int count = 0;

            while(it.hasNext())

            {

                  AttachmentPart part = (AttachmentPart) it.next();

                  attachments[count++] = part;

            }

            return attachments;

      }

 

Greg Hess

Software Engineer

Wrapped Apps Corporation

275 Michael Cowpland Dr.

Suite 201

Ottawa, Ontario

K2M 2G2

Tel: (613) 591 -7552

Fax: (613) 591-0523

1 (877) 388-6742

www.wrappedapps.com

 

<<image001.gif>>

Reply via email to