• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How do I prevent WO5.4 from reading the whole request?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I prevent WO5.4 from reading the whole request?


  • Subject: Re: How do I prevent WO5.4 from reading the whole request?
  • From: Lachlan Deck <email@hidden>
  • Date: Sat, 19 Jan 2008 10:04:06 +1100

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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >How do I prevent WO5.4 from reading the whole request? (From: Bogdan Zlatanov <email@hidden>)
 >Re: How do I prevent WO5.4 from reading the whole request? (From: Mike Schrag <email@hidden>)
 >Re: How do I prevent WO5.4 from reading the whole request? (From: Bogdan Zlatanov <email@hidden>)

  • Prev by Date: Re: D2WQueryToOneRelationship default selection
  • Next by Date: Re: How do I prevent WO5.4 from reading the whole request?
  • Previous by thread: Re: How do I prevent WO5.4 from reading the whole request?
  • Next by thread: Re: How do I prevent WO5.4 from reading the whole request?
  • Index(es):
    • Date
    • Thread