私はWCFを開発しており、SOAP/RESTの両方の方法で呼びたいと思っています。WCF RESTエンドポイント
SOAPで応答を取得できましたが、JSONリクエストで同じWCFを呼び出すことができません。私が直面していますエラー以下
IService1.cs
[OperationContract]
[FaultContract(typeof(CustomException))]
[WebInvoke(Method = "POST", UriTemplate = "/Validateuser",
RequestFormat = WebMessageFormat.Xml | WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Xml | WebMessageFormat.Json)]
ResponsetoCustomer Validateuser(ValidateCustomerInput validate);
のWeb.config
<system.serviceModel>
<services>
<service name="TractorMitraIntegration.IService1" behaviorConfiguration="ServBehave">
<!--Endpoint for SOAP-->
<endpoint
address="soapService"
binding="basicHttpBinding"
contract="TractorMitraIntegration.IService1"/>
<!--Endpoint for REST-->
<endpoint
address="XMLService"
binding="webHttpBinding"
behaviorConfiguration="restPoxBehavior"
contract="TractorMitraIntegration.IService1"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServBehave">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<endpointBehaviors>
<!--Behavior for the REST endpoint for Help enability-->
<behavior name="restPoxBehavior">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
、
コンテンツタイプ 'application/json'が予想されるタイプ 'text/xml'ではないため、メッセージを処理できません。 charset = utf-8 '
助けてください!
あなたはお勧めしますが、運はありません。 HTTP/1.1 415コンテンツタイプ 'application/json'が予期されたタイプ 'text/xml'ではないため、メッセージを処理できません。 charset = utf-8 'となります。 のCache-Control:プライベート サーバー:マイクロソフト-IIS/8.0 X-ASPNET-バージョン:4.0.30319 X-、ソースファイル:????= UTF-8 B RDpcSW5wcm9ncmVzc1xUcmFjdG9yTWl0cmFJbnRlZ3JhdGlvblxUcmFjdG9yTWl0cmFJbnRlZ3JhdGlvblxTZXJ2aWNlMS5zdmNcVmFsaWRhdGV1c2Vy = X-Poweredのバイ:ASP.NET 日付:金曜日、2017年7月14日07:27:55 GMT コンテンツの長さ:0 – Nachiket
WebContentTypeMapperについて調べる必要があるかもしれません。それがajaxの失敗の問題だった場合は、jsonデータに注意を払う必要があります。ストリング化する必要があります。 –