On 18/01/2008, at 8:37 PM, Bogdan Zlatanov wrote:


The real deal is that I'm trying to receive SOAP request that contains large attachments. Because of that my request represents multipart/related and not multipart/form-data, so request ().multipartIterator() is no go.

There is a more interesting part. The same code works just fine on MacOS X Tiger, using WO 5.3, i.e. calling my DA like this .../ wis/mySoapDA and using request().contentInputStream() I managed to
send 700+ MB data. Does this mean that there is a bug in WO5.4?

What if I do something crazy like using DWOAdaptor=<WO5.3 WOAdaptor class>?

Here's how I retrieve a binary attachment from a soap request. (I'm using WO5.3 with Axis 1.1 I believe... hmm should look at updating that + receiving connections with applications running axis 1.4).

with regards,
--

Lachlan Deck


boolean retrieveBinaryAttachment( SOAPBinaryData binaryRecord ) throws RemoteException
{
        if ( this.binaryAttachmentRetrievalCount++ > 0 )
        {
LOG.error( "Attempting to retrieve binary attachment more than once. Multiple binary attachments not supported!", new Exception() );
                return false;
        }
        
        byte[] binaryContent = null;
        MessageContext mc = MessageContext.getCurrentContext();
        Message message = mc.getRequestMessage();
        Attachments messageAttachments = message.getAttachmentsImpl();
        int attachmentCount;
        
        LOG.debug( "retrieveBinary attachment(s)" );
if ( messageAttachments != null && ( attachmentCount = messageAttachments.getAttachmentCount() ) > 0 )
        {
                if ( LOG.isDebugEnabled() )
                        LOG.debug( "attachments count:" + attachmentCount );
                if ( attachmentCount > 1 )
throw new RemoteException( "Only one attachment can be serviced at a time." );
                
AttachmentPart attachment = ( AttachmentPart ) messageAttachments.getAttachments().iterator().next();
                try
                {
                        InputStream is = ( InputStream )attachment.getContent();
                        byte[] buffer = new byte[ 64 * 1024 ];
                        int bytesRead = 0;
                        ByteArrayOutputStream baos = new 
ByteArrayOutputStream();
                        while ( ( bytesRead = is.read( buffer ) ) != -1 )
                        {
                                if ( bytesRead > 0 )
                                        baos.write( buffer, 0, bytesRead );
                        }
                        binaryContent = baos.toByteArray();
                        if ( LOG.isDebugEnabled() )
                                LOG.debug( "retrieveBinary len:" + 
binaryContent.length );
                }
                catch ( SOAPException e )
                {
                        LOG.error( "SOAPException retrieving binary 
attachment", e );
                        return false;
                }
                catch ( IOException e )
                {
                        LOG.error( "IOException retrieving binary attachment", 
e );
                        return false;
                }
                catch ( NullPointerException e )
                {
LOG.error( "NullPointerException retrieving binary attachment [i.e., utilising an old Axis jar or someone forgot to attach something]", e );
                        return false;
                }
        }
        binaryRecord.content = binaryContent;
        return true;
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to