0

Odata は私にとって新しいものであり、深く掘り下げようとしています。そのため、OData プロトコルをアトム形式で使用し、残りのクライアントを使用してデータを挿入しようとしています。そこで、次の http Post リクエストを作成しました。

POST /HelloOdata/library.xsodata/books HTTP/1.1
Host: coe-he-55:8010
Authorization: Basic xxxxxxxxxxxxxxxxxxxxx
DataServiceVersion: 1.0
MaxDataServiceVersion: 2.0
accept: application/atom+xml
Content-Type: application/atom+xml
Cache-Control: no-cache
Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

<?xml version="1.0" encoding="utf-8"?> 
<Entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
    xmlns="http://www.w3.org/2005/Atom">
  <title type="text">books</title> 
  <author> 
    <name /> 
  </author>
        <link href="books('Test_post')/Author" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" title="Author" type="application/atom+xml;type=entry"/>
  <category term="HelloOdata.library.booksType"
      scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
  <content type="application/xml"> 
    <m:properties> 
      <d:title>Test_post</d:title>
      <d:ISBN>ISBN_POST</d:ISBN>
      <d:editions>2</d:editions>
    </m:properties> 
  </content> 
</Entry>

そして、私が得た応答として:シリアル化されたリソースには、メンバー「タイトル」の値がありません。

さて、私のテーブル ブックには、タイトル、ISBN、エディションの 3 つのプロパティしかありません。まさにこのステートメントに挿入しようとしているものです。それで、何が間違っているのか分かりますか?

ありがとうパブロ

4

1 に答える 1

0

エラーの場所がわかりました。信じられないことに、正しい xml リクエストは次のとおりです。

POST /HelloOdata/library.xsodata/books HTTP/1.1
Host: coe-he-55:8010
Authorization: Basic xxxxxxxxxxxxxxxxxxxxx
DataServiceVersion: 1.0
MaxDataServiceVersion: 2.0
accept: application/atom+xml
Content-Type: application/atom+xml
Cache-Control: no-cache
Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

<?xml version="1.0" encoding="utf-8"?> 
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" 
    xmlns="http://www.w3.org/2005/Atom">
  <title type="text">books</title> 
  <author> 
    <name /> 
  </author>
  <category term="HelloOdata.library.booksType"
      scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
  <content type="application/xml"> 
    <m:properties> 
      <d:title>Test_post</d:title>
      <d:ISBN>ISBN_POST</d:ISBN>
      <d:editions>2</d:editions>
    </m:properties> 
  </content> 
</entry>

さて、私もこの部分で降りなければなりませんでした:

 <link href="books('Test_post')/Author" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Author" title="Author" type="application/atom+xml;type=entry"/>

本当の問題はタグだったので、これは最初の試みの後の試みでした

<Entry> 

E ではなく E で書く

<entry>

変更すると、Http リクエストは正常に機能します。

公式 Web サイトのガイドライン ( http://www.odata.org/documentation/odata-version-2-0/operations ) で、OData を使用したデータの挿入のこの例を見ましたが、タグ エントリは大文字で記述されていました。

ありがとうございました!パブロ

于 2014-07-11T12:38:55.483 に答える