2009-03-19 25 views
7

SilverlightからGoogle App Engineを使用する方法についての良い例はありますか?カスタムWebサービスを作成しないことが望ましいですか?Silverlight上のGoogle App Engine

乾杯

ニック

答えて

1

私は同じことをやって考えているが、私はまだ何も遭遇していませんでした。

私はJSON.netを通信に使用することを考えています。したがって、基本的にクライアント用のGAEにRESTサービスを作成し、認証用にOAuth.NETを作成します(ただし、私はまだ見ていません)

Silverlightは基本的に.NETだけです。これは軽いバージョンなので、何かするための.NETコードが見つかると、少なくともSLで動作するはずです。 )

しかし、それは私が持っている限り - 考えている。申し訳ありませんが、まだもっと助けになることはできません!

-3

Expression Blendのためのデモをダウンロードしてください。 GUIモードで豪華なSilverlightインターフェイスを作成し、それをBing検索Webサービスに統合する方法を示す付属のチュートリアルを確認してください。この例をGoogleの例に取り入れることは簡単ではありません。がんばろう! :)

+1

Bling APIがGAEとよく似ているとは思わない –

2

ここに私のアプローチが大きく寄せられていますScott Seely's post XMLを渡すだけで、.xapもGAEによって提供されます。私はちょうど昨日働いているので、まだ進行中です。

グーグル:

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

​​

シルバー:

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(); 
    } 
} 
1

SilverlightがGoogleアプリのJava SDKで動作するようになる例は見つかりませんでしたので、here is my postです。