我有一个问题 - 我需要通过 POST 发送 json,但我的错误是“错误 (415) 无法处理消息,因为内容类型为 application/xml”,显然存在一些不匹配但我找不到它。这是我的 Web.config
<configuration>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="CustomBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="restBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="customBinding" closeTimeout="23:59:59" openTimeout="23:59:59" receiveTimeout="23:59:59" sendTimeout="23:59:59" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="ServiceContracts.Implementation.CR.CRService" behaviorConfiguration="CustomBehavior">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint binding="wsHttpBinding" bindingConfiguration="customBinding" contract="ServiceContracts.CR.ICRService" />
<endpoint binding="webHttpBinding" contract="ServiceContracts.CR.ICRService" behaviorConfiguration="restBehavior" address="rest" />
</service>
<service name="ServiceContracts.Implementation.SP1.SPOneService" behaviorConfiguration="CustomBehavior">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint binding="wsHttpBinding" bindingConfiguration="customBinding" contract="ServiceContracts.SP1.ISPOneService" />
<endpoint binding="webHttpBinding" contract="ServiceContracts.SP1.ISPOneService" behaviorConfiguration="restBehavior" address="rest"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600" />
</requestFiltering>
</security>
</system.webServer>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime executionTimeout="240" maxRequestLength="20480" />
</system.web>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="c:\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>