使用JQuery使用WCF Json服务

时间:2014-04-06 21:11:33

标签: jquery json wcf

在开始之前:我已经阅读了几乎所有关于使用JQuery消费wcf json服务的帖子 - 没有结果。

我有wcf json服务LINK,效果很好。我可以在我的Android应用程序中检索数据,所以我认为WCF的部分不是问题。我的脚本看起来像:

        function btn() {
        $.ajax({
            url: "http://amder.pl/wcftest.svc/GetPracownicy",
            type: "GET",
            processData: true,
            contentType: "application/json",
            timeout: 10000,
            dataType: "json",
            success: function (response) {
                alert(response);
            },      
        });
    };

它不起作用。我花了2个多小时搜索解决方案,尝试了几十个脚本......现在,我请求你帮忙,所以请不要发表评论,比如“使用google ...”等。

这是我的Web.config服务部分:

  <system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>    
<services>
  <service name="amder_01.WCFTest">
    <endpoint contract="amder_01.IWCFTest" kind="webHttpEndpoint" />
  </service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

大多数都基于StackOverflow。

1 个答案:

答案 0 :(得分:0)

您需要为wcf服务配置基本的http端点。您需要在配置文件

中添加类似下面的内容
<service name="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null">
  <endpoint 
      address="/HelloWorld2/"
      contract="HelloWorld, IndigoConfig, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
      binding="basicHttpBinding" />
  </endpoint>
</service>
<bindings>
    <basicHttpBinding 
        receiveTimeout="00:00:01"
    />
</bindings>
相关问题