我收到的错误是“内容类型”应用程序/ json; charset = utf-8'不是预期的类型'text / xml;尝试添加WCF服务时charset = utf-8'Error' .

Javascript代码:

var $jbis = jQuery.noConflict();

var LiveUrl = "http://" + window.location.hostname + "/ISV/CRM.QuoteCopyEntitiesService/";
var serverUrlOData = LiveUrl + "/QuoteCopyEntitiesService.svc";

var jsonParameters = window.JSON.stringify(parameters);

$jbis.support.cors = true;

var dataResult = null;

$jbis.ajax({ type: "POST",
    contentType: "application/json; charset=utf-8",
    datatype: "json",
    async: false,
    data: jsonParameters,
    url: serverUrlOData + functionName,
    beforeSend: function (XMLHttpRequest) {
        /*Specifying this header ensures that the results will be returned as JSON.*/
        XMLHttpRequest.setRequestHeader("Accept", "application/json");
   }, success: function (data, textStatus, XmlHttpRequest) {
        if (data.d != null) {
            dataResult = data.d;
        } else {
            dataResult = data;
        }
    }, error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert("WCF Hata" + errorThrown.toString() + " - " + textStatus.toString());
    }
});

return dataResult;

服务代码:

public Guid CreateQuote(IOrganizationService service, Guid formId)
        {
            ColumnSet cols = new ColumnSet(true);
            Guid cloneId = Guid.Empty;
            Entity retrievedQuote = service.Retrieve("quote", formId, cols);

            Entity clone = Microsoft.Xrm.Client.EntityExtensions.Clone(retrievedQuote, false);
            clone.Attributes.Remove("quoteid");
            clone.Id = Guid.NewGuid();

            cloneId = service.Create(clone);

            return cloneId;
        }

界面

[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        [OperationContract]
        Guid CreateQuote(IOrganizationService service, Guid formId);

WCF中的Web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <httpModules>
            <clear />
        </httpModules>
    </system.web>
    <system.serviceModel>
        <protocolMapping>
            <add scheme="http" binding="webHttpBinding" bindingConfiguration="" />
        </protocolMapping>
        <bindings>
            <webHttpBinding>
                <binding name="webBinding" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="524288" bypassProxyOnLocal="true" useDefaultWebProxy="false">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                </binding>
            </webHttpBinding>
        </bindings>
        <services>
            <service name="QuoteCopyEntitiesService" behaviorConfiguration="QuoteCopyEntitiesService.ServiceBehavior">
                <endpoint address="" behaviorConfiguration="QuoteCopyEntitiesService.EndPointBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="IQuoteCopyEntitiesService" />
            </service>
        </services>
        <behaviors>
            <endpointBehaviors>
                <behavior name="EndPointBehavior">
                    <enableWebScript />
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="QuoteCopyEntitiesService.ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                    <dataContractSerializer maxItemsInObjectGraph="6553600" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true /">
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <directoryBrowse enabled="true" />
    </system.webServer>
</configuration>

我该如何解决?