SOAP-based Amazon S3 Client

I need a Win client for Amazon S3 that uses the SOAP protocol for all transactions. As far as I can see, most solutions are based on REST, not SOAP. Any ideas?

EDIT:

I just want to clarify: please do not suggest using REST instead. I understand very well what can or cannot be done with any protocol. Therefore, if I ask about this particular solution, there is a reason for this.

What I need is working software for the Win platform that uses SOAP for Amazon S3, not suggestions on how to do its job. Thanks.

+4
source share
1 answer
  • Launch Visual Studio 2008, create a new C # Windows console application.

  • Add S3 WSDL as a service link. In Solution Explorer, right-click the link, then select Add Service Link. Enter the S3 WSDL address in the Address field: http://s3.amazonaws.com/doc/2006-03-01/AmazonS3.wsdl . Click Go. AmazonS3 should appear in the Services window. Enter a namespace. I entered Amazon.S3. Click OK.

  • Modify Program.cs to look something like this:


using System; using System.Globalization; using System.Text; using System.Security.Cryptography; using ConsoleApplication1.Amazon.S3; namespace ConsoleApplication1 { class Program { private const string accessKeyId = "YOURACCESSKEYIDHERE0"; private const string secretAccessKey = "YOURSECRETACCESSKEYHEREANDYESITSTHATLONG"; public static DateTime LocalNow() { DateTime now = DateTime.Now; return new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond, DateTimeKind.Local); } public static string SignRequest(string secret, string operation, DateTime timestamp) { HMACSHA1 hmac = new HMACSHA1(Encoding.UTF8.GetBytes(secret)); string isoTimeStamp = timestamp.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture); string signMe = "AmazonS3" + operation + isoTimeStamp; string signature = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(signMe))); return signature; } static void Main(string[] args) { DateTime now = LocalNow(); AmazonS3Client client = new AmazonS3Client(); var result = client.ListAllMyBuckets( accessKeyId, now, SignRequest(secretAccessKey, "ListAllMyBuckets", now)); foreach (var bucket in result.Buckets) { Console.WriteLine(bucket.Name); } } } } 

If you now insert the passkey identifier and secret passkey in the appropriate places and run the program, you should get a list of your S3 codes.

The AmazonS3Client class has all the SOAP operations available as instance methods on it.

The Amazon website presents an earlier (VS2005 + WSE) C # / SOAP sample at http://developer.amazonwebservices.com/connect/entry.jspa?externalID=129&categoryID=47 .

EDIT: posted a visual studio solution at http://flyingpies.wordpress.com/2009/08/04/the-shortest-ever-s3-csoapwcf-client/ .

+3
source

All Articles