Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用WCF服务通过客户端将数据绑定到DropDownList_C#_Jquery_Asp.net_Wcf - Fatal编程技术网

C# 如何使用WCF服务通过客户端将数据绑定到DropDownList

C# 如何使用WCF服务通过客户端将数据绑定到DropDownList,c#,jquery,asp.net,wcf,C#,Jquery,Asp.net,Wcf,我是WCF服务的新手。我想使用ASP.NET中的WCF服务通过jQuery将数据绑定到下拉列表。这是一个简单的$.ajax(…)调用 在WCF中,您可以创建Rest服务(返回JSON)并在jQuery中使用此JSON响应 互联网上有很多例子 c#中的样本(Atom提要): [服务合同] 公共接口INewsFeed { [经营合同] [WebGet] Atom10FeedFormatter GetFeeds(); } 公共类新闻源:INewsFeed { 公共Atom10FeedFormatt

我是WCF服务的新手。我想使用ASP.NET中的WCF服务通过jQuery将数据绑定到
下拉列表。

这是一个简单的
$.ajax(…)
调用

在WCF中,您可以创建Rest服务(返回JSON)并在jQuery中使用此JSON响应

互联网上有很多例子

c#中的样本(Atom提要):

[服务合同]
公共接口INewsFeed
{
[经营合同]
[WebGet]
Atom10FeedFormatter GetFeeds();
}
公共类新闻源:INewsFeed
{
公共Atom10FeedFormatter GetFeeds()
{
SyndicationFeed=new SyndicationFeed(“我的博客提要”,“这是一个测试提要”),new Uri(“http://SomeURI"));
feed.Authors.Add(新建SyndicationPerson(“someone@microsoft.com"));
添加(新的SyndicationCategory(“如何采样代码”);
Description=newTextSyndicationContent(“这是一个演示如何使用RSS和WCF公开提要的示例”);
SyndicationItem1=新的SyndicationItem(
“公共知识”,
“公共知识”,
新Uri(“http://localhost/Content/One"),
“ItemOneID”,
日期时间(现在);
列表项=新列表();
增加(第1项);
feed.Items=项目;
返回新的Atom10FeedFormatter(提要);
}
}
在svc中,您只需添加(工厂零件):


编辑:

<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>


重要的是
在这种情况下,您不需要定义任何端点

谢谢伙计,我也想知道webconfig文件中是否需要任何配置?感谢您的回复,是否有任何简单的WCF示例。我是唯一的学习者。我想要一些简单的例子…看看第9频道的网络广播
<%@ 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>