本帖最后由 hu137919722 于 2013-04-24 15:33:52 编辑

解决方案 »

  1.   

    似乎webHttpEndpoint是rest的?没用过webHttpEndpoint。。要不你改成wsHttpBinding?
      

  2.   

    如果要用RESTful,建议考虑web api
      

  3.   

    本人是wcf初学才几天,对很多东西理解模糊,楼上兄弟说的restful具体是什么?我只是想写能发布在iis上的wcf服务,然后客户端用jquery调用,最好是直接能调用的,不要生成什么代理类那种,我那些代码也是照着网上的例子写的,半懂不懂,现在情况是我发布的服务不仅jquery不能调用,连svcutil或者引用服务的时候都没有客户端文件,只有代理类
      

  4.   

    很抱歉,jquery调用wcf这个没有做过,所以不太了解。
    如果要被jquery调用为啥不用ajax?
      

  5.   

    这个有不同吗,类似这样的
            $(function () {
                $.ajax({
                    type: "get",
                    url:"http://172.168.1.158:1945/Service1.svc/CategorySearch?jsoncallback=?",
                    dataType: "json",
                    success: function (employees) {
                        $.each(employees, function (index, value) {
                            var detailUrl = "detail.html?id=" + value.Category1Code;
                            var html = "<tr><td>";
                            html += value.Category1Code + "</td><td>";
                            html += "<a href='" + detailUrl + "'>" + value.ProductCategory1 + "</a></td><td>";
                            html += value.Category1Code + "</td><td>";
                            html += value.ProductCategory1 + "</td></tr>";
                            $("#employees").append(html);
                        });
                        $("#employees tr:odd").addClass("oddRow");
                    }
                });        });
      

  6.   

    前台这样写对吗?还有这样写过        $(function () {
                $.ajax({
                    type: "get",
                    url:"http://172.168.1.158:1945/Service1.svc/CategorySearch/hutianyi",
                    dataType: "jsonp",
                    success: function (employees) {
                        $.each(employees, function (index, value) {
                            var detailUrl = "detail.html?id=" + value.Category1Code;
                            var html = "<tr><td>";
                            html += value.Category1Code + "</td><td>";
                            html += "<a href='" + detailUrl + "'>" + value.ProductCategory1 + "</a></td><td>";
                            html += value.Category1Code + "</td><td>";
                            html += value.ProductCategory1 + "</td></tr>";
                            $("#employees").append(html);
                        });
                        $("#employees tr:odd").addClass("oddRow");
                    }
                });        });后台实现方法前面加了这个 [WebGet(UriTemplate="hutianyi", ResponseFormat = WebMessageFormat.Json)],
    结果还是调用不了,但是我在浏览器里面都能访问服务,也可以直接用这个url:http://172.168.1.158:1945/Service1.svc/CategorySearch/hutianyi 调到数据,不明白
      

  7.   

    那你说的那个用webapi在我这个里面应该怎么搞啊?我被这个配置搞疯了
      

  8.   

    似乎是服务器端serviceMetadata 没有开启。
    配置文件中在system.servicemodel节点添加
    <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>试试
      

  9.   

    什么意思?我就是发布到iis上的,和发布网站一样,发布后浏览器里也能访问的,如果加了那个WebGet(UriTemplate="hutianyi", ResponseFormat = WebMessageFormat.Json)]的话,浏览器里都能直接取到数据,就是jquery访问不了,也生成不了客户端配置文件
      

  10.   

    你既然用jquery ajax了,通过ajax获取的数据是CategoryListBLL 这样的list,jquery能够识别吗?我只做过把这些数据做成json格式或者xml格式的text数据然后由jquery遍历。
    还有你客户端config生成不了把wcf的配置webHttpEndpoint和wsHttpBinding分别都试一下看看。
      

  11.   

    WCF开发实战系列二:使用IIS发布WCF服务
      

  12.   


    我传到前台是json数据,list在后台已经自动转为json了
      

  13.   

    各位有没有谁有这方面的代码啊,就是用来在iis上发布的服务,然后前台jquery ajax调用的一个完整代码,我学习学习,网上下的看过了,要么太简单,要么就没用,我邮箱[email protected],谢过了。。
      

  14.   

    唉,我现在也不想jquery能不能调用了,只想搞清楚为什么不能生成客户端配置文件
      

  15.   

    web.config 有:
    <modules runAllManagedModulesForAllRequests="true"/>
    这项配置后,jquery就不能调用,不知道为什么。