.NET Connection to Google’s Application Engine Datastore

I was excited to hear that Google was delivering a new platform that would provide inexpensive, scalable storage.  Unfortunately, the Application Engine was a little more than I expected.  Instead of an API into a massive storage cloud, Google released a Python-based application hosting service.  Even though I don’t know Python, I decided to try my hand at some code.  My first project was Links ‘R’ Us, a tiny url service.  I realized after building Links ‘R’ Us that I had all of the knowledge that I needed to build a simple Soap wrapper around Google’s Datastore classes.  With this wrapper, any .NET developer can use Google as a storage option.  So when you clean an engine with soap, what do they call that product…oh, yeah, GUNK!

Introducing GUNK

GUNK is a simple Soap wrapper built as a Python application.  It allows .NET developers to connect to Google’s Application Engine Datastore through a web service.  Although a default Datastore is created in the code, a developer could modify GUNK to use additional datastores or expand the properties of the default datastore.

If you are already familiar with Amazon’s S3 service, the GUNK service should make sense.  Data is stored in Name/Value pairs and organized into Buckets.  Unlike S3, creating a Bucket is not a separate process.  Buckets are just a way to easily organize your data and you can increase the levels of buckets or simply remove the bucket concept altogether if you like.

Setting Up GUNK

  1. Download and install the Google App Engine SDK.  Follow the steps for installing Python.
  2. Download the GUNK code from the project site.
  3. Create an application directory in your google_appengine folder and copy all of the project files into the folder.
  4. Modify main.py.  Change the values for “self.ns” and “self.secret” to your desired settings.
  5. Start your dev web server for the GUNK project and navigate in your browser to the site.  You should see the GUNK WSDL.

 

.NET and GUNK

  1. See the special instructions page on additional .NET configuration.
  2. You will probably not be able to add the GUNK.WSDL directly from the dev web server.
    • Copy GUNK.WSDL to your .NET project root.  Modify the following values: 
    • {{ns}} – The target namespace uri.  This should match your setting in main.py.
    • {{location}} – This is the app engine web site, example:  http://localhost:8080/
    • Add a new Web Reference using the WSDL that you just modified.
  3. If you want to match the examples, your Web Reference folder name will be “com.appspot.gunk”
  4. Make sure that the web reference points to your dev server (Google, not .NET) in web.config.
  5. You can use the example code to test GUNK.  Just add the class code to the code-behind of an ASPX page.

 

com.appspot.gunk.GUNK gunk = new com.appspot.gunk.GUNK();
//Test Put
results = “”;
results = gunk.Put(secret, bucket, name, value);
Response.Write(“<p>Put: ” + results + “</p>”);
//Test Get  
results = “”;
results = gunk.Get(secret, bucket, name);
Response.Write(“<p>Get: ” + Server.HtmlEncode(results)
+ “</p>”);
//Test Delete
results = “”;
results = gunk.Delete(secret, bucket, name);
Response.Write(“<p>Delete: ” + results + “</p>”);

 

Gunk Methods

GUNK provides a Put, Get, and Delete method.  Additional methods may be added later, but these methods allow you to perform typical operations.  The “Secret” must match the secret in your Python file, “main.py.”  The Bucket, Name, and Value arguments can be anything you like.

Return values for Put and Delete will be “true” or “false” strings.

The return value for the Get method is a string in the form of an XML document.  This Xml “entity” structure is produced by Google through a call to to_xml() in main.py

 

You can contribute to the GUNK project, although I’m not sure how long it will be necessary.  I hope that eventually a Google supported .NET codebase will be developed.  In the meantime, give GUNK a try, and join the discussion group if you want to talk about GUNK or just .NET and Google App Engine in general.

  • Share/Bookmark

2 Comments so far »

  1. Google Application Engine: Free Data Storage for .NET Applications « Shannon Whitley said,

    Wrote on April 17, 2008 @ 7:20 am

    [...] my last post, I described how one might setup the development environment on your local machine and start [...]

  2. Google App Engine over lunch « I was just thinking… said,

    Wrote on June 11, 2008 @ 10:40 am

    [...] Next up is Shannon, who explains how .NET can leverage GAE through abstraction via a webservice call. [...]

Comment RSS · TrackBack URI

Leave a Comment

Name: (Required)

E-mail: (Required)

Website:

Comment:

Twitter Users!
Enter your personal information in the form or sign in with your Twitter account by clicking the button below.