私は ajax 対応の WCF を使用しています。Web ブラウザーで URL を開くと、このエラーが発生します。
アクション ' http://localhost:22219/MobileService.svc/GetProductCategories ' を含むメッセージは、EndpointDispatcher での ContractFilter の不一致により、受信側で処理できません。これは、コントラクトの不一致 (送信者と受信者の間のアクションの不一致) または送信者と受信者の間のバインディング/セキュリティの不一致が原因である可能性があります。送信者と受信者が同じコントラクトと同じバインド (メッセージ、トランスポート、なしなどのセキュリティ要件を含む) を持っていることを確認します。
MobileService コードを以下に示します
namespace MobileService
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MobileService
{
// To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
// To create an operation that returns XML,
// add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
// and include the following line in the operation body:
// WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
[OperationContract]
public void DoWork()
{
// Add your operation implementation here
return;
}
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetProductCategories")]
public List<String> GetProductCategories()
{
List<String> categoryList = new List<string>();
categoryList.AddRange(new String[] { "Electronics", "Housewares", "Computers", "Software", "Music" });
return categoryList;
}
// Add more operations here and mark them with [OperationContract]
}
}
AND サービスの web.config ファイルは
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="MobileService.MobileServiceAspNetAjaxBehavior">
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="MobileService.MobileService">
<endpoint address="" behaviorConfiguration="MobileService.MobileServiceAspNetAjaxBehavior"
binding="webHttpBinding" contract="MobileService.MobileService" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
私が間違いを犯した場所で誰かが私を助けることができますか?