Welcome to MSDN Blogs Sign in | Join | Help

在 Azure 中使用 AJAX 呼叫 WCF 的服務

上一篇文章中,可以知道如何將開發好的應用程式上傳到 Azure Services Portal 中。

接著一定要來測試一下一些重要的技術是否也可以相容?

俗話說:『眼見為憑』。

所以我們就來使用一個簡易的範例來證明在 Azure 中是否可以使用 AJAX 來呼叫 WCF 服務。

 

範例很簡單,輸入兩個數字,由 WCF 的服務提供  加、減、乘、除   的服務。

image

 

網址為止:http://taiwan.cloudapp.net/ 

大家可以自行測試這個程式。(筆者會陸續測試不同的程式,所以您連到這個網址,可能會看到不同的程式)

 

如何證明這是真的呼叫 WCF 的服務,不是個晃子呢?

我們可以直接在網址列輸入 http://taiwan.cloudapp.net/service.svc/Add?n1=10&n2=20

其回傳為 30 (JSON 格式),因為筆者在 WCF 的 Add 方法有加入 [WebGet] 屬性,您也可以透過這個方式叫用。

 

由上述可知,筆者的這個 WCF 的服務係金的。

 

當然也證明 Azure Services Platform 可以支援 AJAX 及 WCF。

 

筆者使用的環境界:Windows 7 Beta + VS 2008 SP1 + Azure SDK(Jan 2009) + Azure Tool for VS(Jan 2009)

Enjoy.

Published Monday, January 19, 2009 5:52 PM by jchiou
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker