Hello all,

I'm having a problem with obtaining a PDF from a webservice as an
attachment. The first time I call the web service, everything works as
it is expected, but the second time, the client side seems to hang on
reading the file. Here's the code:

Server:
public javax.activation.DataHandler getProduct(java.lang.String name,
                                                                      
                 java.lang.String datasetName)
                                                                      
       throws java.rmi.RemoteException {
   // Stuff to determine 'product' snipped.
    javax.activation.DataHandler dh = new javax.activation.DataHandler(
            new javax.activation.FileDataSource(product));
    log.debug("Content type is: ["+dh.getContentType()+"]");
    org.apache.axis.MessageContext msgCtx = 
            org.apache.axis.MessageContext.getCurrentContext();
    org.apache.axis.Message response=msgCtx.getResponseMessage();
    response.getAttachmentsImpl().setSendType(
                      org.apache.axis.attachments.Attachments.SEND_TYPE_MIME);
    org.apache.axis.attachments.AttachmentPart attachment = 
                        new org.apache.axis.attachments.AttachmentPart(dh);
    response.addAttachmentPart(attachment);
    log.debug("Returning product "+name);
}

Client:
javax.activation.DataHandler data =
                    service.getProduct(myForm.getProductName(),
myForm.getName());
if (null == data) {
                log.debug("No product obtained from web service.");
                return null;
            }
 log.debug("Obtaining attachment for product ["+myForm.getProductName()+"]");
java.io.InputStream is = data.getInputStream();

I am using axis-1_2RC2, javamail-1.3.2, jaf-1.0.2. It works fine if
the file is a PNG or a GIF or a HTML document instead. The PDF is of
course bigger than all of these, I also have this problem with a
zipped postscript file (is not unpacked, is just sent as a gzipped
file).

I'd be very grateful if someone could give me some pointers.

Ian.

Reply via email to