wcf服务iis发布成功,浏览器也能访问调数据,但是无法生成客户端配置文件,jquery也不能调用,该如何处理
wcf服务iis发布成功,浏览器也能访问调数据,但是无法生成客户端配置文件,jquery也不能调用
wcf服务iis发布成功,浏览器也能访问调取数据,但是无法生成客户端配置文件,我看到网上说的用svcutil工具或者直接添加服务引用就能生成客户端配置文件,但是我的就是没有客户端配置文件,代理类都是有的,jquery也不能调用,不知道是我的配置那里出了问题,希望大家帮忙看看,谢了!
配置文件
契约和实现代码
------解决思路----------------------
如果要用RESTful,建议考虑web api
------解决思路----------------------
你既然用jquery ajax了,通过ajax获取的数据是CategoryListBLL 这样的list,jquery能够识别吗?我只做过把这些数据做成json格式或者xml格式的text数据然后由jquery遍历。
还有你客户端config生成不了把wcf的配置webHttpEndpoint和wsHttpBinding分别都试一下看看。
------解决思路----------------------
WCF开发实战系列二:使用IIS发布WCF服务
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
------解决思路----------------------
你既然用jquery ajax了,通过ajax获取的数据是CategoryListBLL 这样的list,jquery能够识别吗?我只做过把这些数据做成json格式或者xml格式的text数据然后由jquery遍历。
还有你客户端config生成不了把wcf的配置webHttpEndpoint和wsHttpBinding分别都试一下看看。
------解决思路----------------------
WCF开发实战系列二:使用IIS发布WCF服务