Posts Tagged web services

Amazon S3 Library for SOAP in Java


After trying to run the code based on this blog, it suddenly just doesn’t work!

Recommend you look at JetS3t which provides a nice wrapper around the S3 SOAP stuff.

The main reason not to the S3 SOAP directly is because signing requests is a complete pain in the ass.

Woe is me!

After looking a lot of tools, I decided I need to write a one-off for my application to update ACL’s. All the tools I found wanted to pull back every ACL and update it! I want all my keys in this part of my bucket to have the same ACL.

I tried to use the wsimport’d library, but…. The SOAP 1.1 request is missing a security element
    at $Proxy33.getObjectAccessControlPolicy(Unknown Source)
    at us.versus.them.jarczar.publisher.AppTest.testApp(

OSS to the Rescue

I cursed and cried and then found the Amazon S3 Library for SOAP in Java. The only bit I really wanted was which takes care of the blasted authentication nonsense.

Compiling s3-example-libraries

Compiling it was fun:

% javac -d out $( find com -name "*.java" ) -classpath ${HOME}/.m2/repository/org/codehaus/castor/castor/1.2/castor-1.2.jar:${HOME}/.m2/repository/org/apache/axis/axis/1.4/axis-1.4.jar:${HOME}/.m2/repository/com/sun/javaee/javaee/5.0/javaee-5.0.jar
% jar cf  s3-example-libraries.jar -C out .
% 1.0.0 s3-example-libraries.jar

Using it

Using it was trivial:

import com.amazonaws.s3.doc._2006_03_01.*;


AWSAuthConnection aws = new AWSAuthConnection( awsAccessKeyId, awsSecretAccessKey );
AccessControlPolicy acl = aws.getACL( bucket, key );

Maven Dependencies

It did pull in a few deps....


Leave a Comment