Monday, December 31, 2012

Google App Engine on Silverlight

Google App Engine on Silverlight

are there any good examples on how to use Google App Engine from Silverlight, preferably without writing custom webservices?

Cheers

Nik

Answers & Comments...

Answer: 1

I'm thinking about doing the same thing, but I've not come across anything yet.

I'm thinking about using JSON.net for the comms, so basically writing a REST service in GAE for the client to call, and maybe OAuth.NET for the authentication (unless I can find the .NET port of the google one, I've not looked yet)

Silverlight is basically just .NET, tho a lite version of it, so if you can find .NET code to do something, it should work, atleast somewhat, in SL :)

But thats as far as I've got - thinking about it. Sorry, can't be of more help yet!

by : Nic Wisehttp://stackoverflow.com/users/2947

Answer: 2

I'm looking at this also. There are several REST projects for GAE, I haven't tried any of them out yet, but hope to in the next week or so.

http://code.google.com/p/app3/

http://code.google.com/p/gae-json-rest/

http://code.google.com/p/appengine-rest-server/

by : Leroyhttp://stackoverflow.com/users/11085

Answer: 3

Check this out:

http://www.informit.com/articles/article.aspx?p=1354698

by : Neo42http://stackoverflow.com/users/125062

Answer: 4

Download the demo for Expression Blend. Check the included tutorial which shows how to create a gorgeous Silverlight interface in GUI mode and integrate it with the Bing search web service. Manipulating this example into a Google example should be trivial. Good luck! :)

by : danglundhttp://stackoverflow.com/users/134850

Answer: 5

Here is my approach based heavily on Scott Seely's post Simply passes XML around, .xap is also served by GAE. I only just got this working yesterday so it is still work in progress.

Google:

app.yaml

    application: wowbosscards version: 1 runtime: python api_version: 1  handlers: - url: /WowBossCards.html   static_files: WowBossCards.html   upload: WowBossCards.html   mime_type: text/html - url: /clientaccesspolicy.xml   static_files: clientaccesspolicy.xml   upload: clientaccesspolicy.xml   mime_type: text/xml - url: /WowBossCards.xap   static_files: WowBossCards.xap   upload: WowBossCards.xap   mime_type: application/x-silverlight-app - url: .*   script: wowbosscards.py 

wowbosscards.py

#!/usr/bin/env python  import cgi import datetime import wsgiref.handlers import os import logging import string import urllib  from google.appengine.ext import db from google.appengine.api import users from google.appengine.ext import webapp from google.appengine.ext.webapp import template  class Xml(db.Model):   xmlContent = db.TextProperty()   date = db.DateTimeProperty(auto_now_add=True)   class XmlCrud(webapp.RequestHandler):   def get(self, xmlType):      xmlKey = string.capitalize(xmlType)     xml = Xml.get_by_key_name(xmlKey)     self.response.headers['Content-Type'] = "application/xml"      self.response.out.write(xml.xmlContent)    def post(self, xmlType):      logging.debug("XmlCrud POST")     xmlKey = string.capitalize(xmlType)     xml = Xml.get_by_key_name(xmlKey)     if len(self.request.get('content')) > 0 :         xml.xmlContent = self.request.get('content')     else:         xml.xmlContent = self.request.body     xml.put()      self.redirect('/upload/' + xmlType)   def main():   Xml.get_or_insert("Bosses", xmlContent="<a>Bosses go here</a>")   Xml.get_or_insert("Dungeons", xmlContent="<a>Dungeons go here</a>")   application = webapp.WSGIApplication([     									  (r'/xml/(.*)', XmlCrud),     									], debug=True)   wsgiref.handlers.CGIHandler().run(application)   if __name__ == '__main__':   main() 

Silverlight:

private class RequestExtended {     public VoidCall CallBack;     public WebRequest Request;     public Uri Host;      public RequestExtended(WebRequest request, VoidCall callBack, Uri host)     {         Request = request;         CallBack = callBack;         Host = host;     } }  public static void ImportFromGoogle(Uri host, VoidCall callBack) {     try     {         if (host.Host == "localhost")         {             host = new Uri(host.Scheme + @"://" + host.Host + ":8080");         }         var bossesCrud = new Uri(host, "/xml/bosses");         var bossesRequest = WebRequest.Create(bossesCrud);         bossesRequest.BeginGetResponse(BossesResponse, new RequestExtended(bossesRequest, callBack, host));     }     catch (Exception ex)     {      } }  public static void BossesResponse(IAsyncResult result) {     var requestExtended = result.AsyncState as RequestExtended;     try     {         WebResponse response = requestExtended.Request.EndGetResponse(result);         Stream responseStream = response.GetResponseStream();          byte[] bytes = new byte[response.ContentLength];         responseStream.Read(bytes, 0, bytes.Length);         responseStream.Close();          var enc = new System.Text.UTF8Encoding();         string xml = enc.GetString(bytes, 0, bytes.Length);          bosses = GetCollectionFromXmlString<BossCollection>(xml);          if (requestExtended.CallBack != null) requestExtended.CallBack();     }     catch (WebException we)     {         HttpWebResponse response = (HttpWebResponse)we.Response;         response.Close();     }     catch (Exception e)     {     } }     public static void SaveBossesToGoogle(Uri host) {     if (host.Host == "localhost")     {         host = new Uri(host.Scheme + @"://" + host.Host + ":8080");     }     var bossesCrud = new Uri(host, "/xml/bosses");     var request = WebRequest.Create(bossesCrud);     request.Method = "POST";     request.ContentType = "text/xml"; //"application/x-www-form-urlencoded";      request.BeginGetRequestStream(GetSaveBossesRequestStreamCallback, new RequestExtended(request, null, host)); }  static void GetSaveBossesRequestStreamCallback(IAsyncResult result) {     var requestExtended = result.AsyncState as RequestExtended;     try     {         Stream stream = requestExtended.Request.EndGetRequestStream(result);         var xmlSerializer = new XmlSerializer(typeof(BossCollection));         var xmlText = new StringBuilder();          using (TextWriter textWriter = new StringWriter(xmlText))         {             xmlSerializer.Serialize(textWriter, Store.Bosses);             textWriter.Close();         }          var enc = new System.Text.UTF8Encoding();         var bytes = enc.GetBytes(xmlText.ToString());          stream.Write(bytes, 0, bytes.Length);         stream.Close();         requestExtended.Request.BeginGetResponse(SaveResponse, requestExtended);     }     catch (WebException we)     {         HttpWebResponse response = (HttpWebResponse)we.Response;         response.Close();     } }   static void SaveResponse(IAsyncResult result) {     var requestExtended = result.AsyncState as RequestExtended;     try     {         WebResponse response = requestExtended.Request.EndGetResponse(result);         if (requestExtended.CallBack != null) requestExtended.CallBack();     }     catch (WebException we)     {         HttpWebResponse response = (HttpWebResponse)we.Response;         response.Close();     } } 
by : Sam Mackrillhttp://stackoverflow.com/users/18349

Answer: 6

I couldn't find any examples getting Silverlight to work with google app's Java SDK, so here is my post.

by : Keld Ølykkehttp://stackoverflow.com/users/0




5 comments:

Anonymous said...

Hello, everything is going perfectly here and ofcourse every one is sharing information, that's in fact excellent, keep up writing.

Feel free to visit my weblog :: binary options platforms
my web site > binary forex options

Anonymous said...

Thanks for every other great article. The place else may anybody get that type of info in such an ideal means of writing?
I have a presentation next week, and I'm at the look for such info.

Visit my website; Clases De musica

Anonymous said...

Heya i'm for the first time here. I found this board and I find It really useful & it helped me out a lot. I hope to give something back and help others like you helped me.

My homepage :: ventanas

Anonymous said...

Hello, I think your blog might be having browser compatibility
issues. When I look at your website in Firefox, it looks fine but when opening in Internet
Explorer, it has some overlapping. I just wanted to give you a quick heads up!
Other then that, fantastic blog!

Feel free to surf to my web site ... ScotteVest Canada

Anonymous said...

I'm really enjoying the design and layout of your website. It's a very
easy on the eyes which makes it much more enjoyable for me to
come here and visit more often. Did you hire out a designer to create your theme?
Exceptional work!

Take a look at my website: rimowa canada

Post a Comment

Send us your comment related to the topic mentioned on the blog