wcf服务iis发布成功,浏览器也能访问调数据,但是无法生成客户端配置文件,jquery也不能调用,该如何处理

wcf服务iis发布成功,浏览器也能访问调数据,但是无法生成客户端配置文件,jquery也不能调用
本帖最后由 hu137919722 于 2013-04-24 15:33:52 编辑
wcf服务iis发布成功,浏览器也能访问调取数据,但是无法生成客户端配置文件,我看到网上说的用svcutil工具或者直接添加服务引用就能生成客户端配置文件,但是我的就是没有客户端配置文件,代理类都是有的,jquery也不能调用,不知道是我的配置那里出了问题,希望大家帮忙看看,谢了!

配置文件

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>

    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint crossDomainScriptAccessEnabled="true" />
      </webHttpEndpoint>
    </standardEndpoints>
    <bindings>
      <webHttpBinding>
        <binding name="webbinding" crossDomainScriptAccessEnabled="true" />
      </webHttpBinding>
    </bindings>
    <services>
      <service name="ePDP.WCF.CategorySearch">
        <endpoint address="CategorySearch" kind="webHttpEndpoint" contract="ePDP.WCF.ICategorySearch" behaviorConfiguration="AjaxWCFServiceAspNetAjaxBehavior" />
      </service>
    </services>
    
    <behaviors>
      <endpointBehaviors>
        <behavior name="AjaxWCFServiceAspNetAjaxBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  
</configuration>



契约和实现代码

    [ServiceContract]
    public interface ICategorySearch
    {
        [OperationContract]
        List<CategoryBDU> GetCategory();
    }


    [AspNetCompatibilityRequirements(RequirementsMode =    AspNetCompatibilityRequirementsMode.Allowed)]
    [JavascriptCallbackBehavior(UrlParameterName = "jsoncallback")]
    public class CategorySearch : ICategorySearch
    {
        CategoryReader cateReader;

        public CategorySearch()
        {
            cateReader = new CategoryReader();
        }
        //[WebGet(ResponseFormat = WebMessageFormat.Xml)]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]//UriTemplate = "humengzheng",
        public List<CategoryBDU> GetCategory()
        {
            List<CategoryBDU> CategoryListBLL = new List<CategoryBDU>();
            int status = cateReader.Category1Reader(out CategoryListBLL);
            return CategoryListBLL;
        }
    }

------解决思路----------------------
如果要用RESTful,建议考虑web api
------解决思路----------------------
引用:
这个。。。有不同吗,类似这样的



JavaScript code
?



123456789101112131415161718192021

        $(function () {             $.ajax({                 type: "get",                 url:"http://172.168.1.15……

你既然用jquery ajax了,通过ajax获取的数据是CategoryListBLL 这样的list,jquery能够识别吗?我只做过把这些数据做成json格式或者xml格式的text数据然后由jquery遍历。
还有你客户端config生成不了把wcf的配置webHttpEndpoint和wsHttpBinding分别都试一下看看。
------解决思路----------------------
引用:
引用:你怎么发布的?
你的宿主的配置文件了?
什么意思?我就是发布到iis上的,和发布网站一样,发布后浏览器里也能访问的,如果加了那个WebGet(UriTemplate="hutianyi", ResponseFormat = WebMessageFormat.Json)]的话,浏览器里都能直接取到数据,就是jquery访问不了,也生……



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