1

このチュートリアルに従って、odata サービスを使用しようとしています

http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/getting-started-with-odata-in-web-api/create-an-odata-client

チュートリアルの指示に従って、WCF Data Services Tools 5.2 をダウンロードしてインストールしました。

ただし、サービス参照を追加しようとすると、次のエラーが発生します。

The document at the url http://localhost:52868/odata/Products was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'Data at the root level is invalid. Line 1, position 1.'.
- Report from 'DISCO Document' is 'Data at the root level is invalid. Line 1, position 1.'.
- Report from 'WSDL Document' is 'There is an error in XML document (1, 1).'.
  - Data at the root level is invalid. Line 1, position 1.
Metadata contains a reference that cannot be resolved: 'http://localhost:52868/odata/Products'.
The content type application/json; odata=minimalmetadata; streaming=true; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '{
  "odata.error":{
    "code":"","message":{
      "lang":"en-US","value":"An error has occurred."
    },"innererror":{
      "message":"No MediaTypeFormatter is available to read an object of type 'Product' from content with media type 'application/soap+xml'.","type":"System.InvalidOperationException","stacktrace":"   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)\r\n   at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)\r\n   at System.Web.Http.ModelBinding.FormatterParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)\r\n   at System.Web.Http.OData.PerRequestParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancel'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again.

ただし、ブラウザ経由で閲覧できます。

なにが問題ですか?

4

1 に答える 1

0

チュートリアルの間違いかどうかわかりませんが、ウリでいろいろ試してみたのですが、http://localhost:52868/odata参考に追加してもうまくいきhttp://localhost:52868/odata/Productsません

于 2013-02-19T10:54:05.407 に答える