[英]how to use silverlight enables wcf web service in javascript
我們有一個wcf Web服務,該服務被開發為支持Silverlight的wcf Web服務,用於從silverlight應用程序訪問數據庫。 現在,我們希望使用與JavaScript相同的WCF服務。 是否可以在javascript中調用啟用了Silverlight的WCF Web服務
是的,有可能,您只需要將Json Endpoint添加到服務合同中並轉換您的方法即可返回Json數據,
例如,
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "login/{username}/{password}",BodyStyle = WebMessageBodyStyle.Bare)]
UserAuth login(string username, string password);
對的,這是可能的。
http://www.bendewey.com/index.php/186/using-jsonp-with-wcf-and-jquery
修改類定義[ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]公共類CustomersService {/////}
保持silverlight方法不變,並添加如下所示的Json方法。
[OperationContract] [WebGet(ResponseFormat = WebMessageFormat.Json)]公共列表GetCustomers(int d){返回列表; }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.