1
我是WCF服務的新手。我想在ASP.NET中使用WCF服務通過jQuery將數據綁定到DropDownList
。如何通過客戶端使用WCF服務將數據綁定到DropDownList
我是WCF服務的新手。我想在ASP.NET中使用WCF服務通過jQuery將數據綁定到DropDownList
。如何通過客戶端使用WCF服務將數據綁定到DropDownList
這是一個簡單的通話$.ajax(..)
http://api.jquery.com/jQuery.ajax/
在WCF中,你可以在jQuery的
http://msdn.microsoft.com/en-us/netframework/dd547388
在互聯網例如大量的創建REST服務(返程JSON)和消費這JSON響應。
樣品在C#(Atom供稿):
[ServiceContract]
public interface INewsFeed
{
[OperationContract]
[WebGet]
Atom10FeedFormatter GetFeeds();
}
public class NewsFeed : INewsFeed
{
public Atom10FeedFormatter GetFeeds()
{
SyndicationFeed feed = new SyndicationFeed("My Blog Feed", "This is a test feed", new Uri("http://SomeURI"));
feed.Authors.Add(new SyndicationPerson("[email protected]"));
feed.Categories.Add(new SyndicationCategory("How To Sample Code"));
feed.Description = new TextSyndicationContent("This is a how to sample that demonstrates how to expose a feed using RSS with WCF");
SyndicationItem item1 = new SyndicationItem(
"Lorem ipsum",
"Lorem ipsum",
new Uri("http://localhost/Content/One"),
"ItemOneID",
DateTime.Now);
List<SyndicationItem> items = new List<SyndicationItem>();
items.Add(item1);
feed.Items = items;
return new Atom10FeedFormatter(feed);
}
}
和SVC中,你只需要添加(廠部分):
<%@ ServiceHost Language="C#" Debug="true" Service="RssReader.Wcf.NewsFeed" CodeBehind="NewsFeed.svc.cs" Factory=System.ServiceModel.Activation.WebServiceHostFactory%>
編輯:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
重要部分是<serviceMetadata httpGetEnabled="true"/>
在這種情況下,你不需要定義任何端點
感謝兄弟我也想知道是否有任何配置需要在webconfig文件? – YogeshWaran
我已經在編輯中加入了必要的配置。 –
感謝您的回覆,WCF有任何簡單的例子。我只是學習者。我想要一些簡單的例子... – YogeshWaran