首页 新闻 赞助 找找看

wcf web.config 配置跨域请求错误!!!!

1
[已关闭问题] 关闭于 2013-09-01 22:24
<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  
  <system.serviceModel>
    <services>
      <service name="CalendarService.Service" behaviorConfiguration="CalendarService.ServiceBehavior">
        <endpoint address="/CalendarService/web" binding="webHttpBinding" behaviorConfiguration="webJSBehavior"
                  bindingConfiguration="webBinding" contract="CalendarService.IService"/>
        <endpoint address="/CalendarService" binding="basicHttpBinding" contract="CalendarService.IService"></endpoint>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webJSBehavior">
          <enableWebScript />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="CalendarService.ServiceBehavior">
          <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
          <serviceMetadata httpGetEnabled="true"  httpGetUrl="/Service.svc/metadata"/>
          <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="webBinding" crossDomainScriptAccessEnabled="true"/>
      </webHttpBinding>
    </bindings>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
        在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace CalendarService
{
    // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService”。
    [ServiceContract]
    public interface IService
    {
        [OperationContract]
        [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
        void DoWork();

       
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;

namespace CalendarService
{
    // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名“Service”。
    // 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 Service.svc 或 Service.svc.cs,然后开始调试。
    [AspNetCompatibilityRequirements(
       RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [JavascriptCallbackBehavior(UrlParameterName = "jsoncallback")]
    public class Service : IService
    {
        public void DoWork()
        {
        }

       
    }
}

创建了一个wcf服务程序 想发布到iis 然后 jquery跨域请求 但发布了访问不了 比如访问http://localhost:8083/Service.svc 就会有如下错误

正文样式“Wrapped”不受“WebScriptEnablingBehavior”支持。请将正文样式更改为“WrappedRequest”。

koi的主页 koi | 初学一级 | 园豆:4
提问于:2013-08-01 16:08
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册