axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "I-Sampige, Srinivas" <>
Subject RE: Client accessing MessageContext?
Date Thu, 13 Nov 2003 22:07:41 GMT
Well, I am doing a similar code for receiving attachments works -

Client snippet...

          String[] array = new String[1];
          array[0] = "hello";
          org.apache.axis.MessageContext messageContext = call.getMessageContext();
          org.apache.axis.Message currentMessage = messageContext.getCurrentMessage();
          currentMessage.addAttachmentPart(new AttachmentPart(dh));

          String returnValue = (String) call.invoke(array);
          org.apache.axis.Message responseMessage =  messageContext.getResponseMessage();
          System.out.println("Number of attachments is -> "+responseMessage.countAttachments());

Server code snippet..
      org.apache.axis.MessageContext messageContext =  org.apache.axis.MessageContext.getCurrentContext();
      org.apache.axis.Message responseMessage = messageContext.getResponseMessage();
      org.apache.axis.Message requestMessage = messageContext.getResponseMessage();


      responseMessage.addAttachmentPart(new AttachmentPart(dh));
      responseMessage.addAttachmentPart(new AttachmentPart(dh1));

I would check if to see if the attachments are being attached properly on the server side.


-----Original Message-----
From: Greg Hess [] 
Sent: Thursday, November 13, 2003 1:37 PM
Subject: Client accessing MessageContext?

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;
                  AttachmentPart part = (AttachmentPart);
                  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


View raw message