【问题标题】:406 Not acceptable while performing post on ODATA4j406 在 ODATA4j 上执行 post 时不可接受
【发布时间】:2011-12-30 06:42:35
【问题描述】:

我是 odata4j 概念的新手。 使用 odata4j 库 odata4j-0.5-nojpabundle.jar 使用链接在 tomcat 上启动生产者 http://code.google.com/p/odata4j/wiki/Tomcat。 我的生产者被修改为提供大量整数作为实体集,称为“整数” 我可以检索 serviceDoc、collection 并可以应用过滤器。 现在尝试在此服务文档上执行发布[尝试添加一个具有相同架构的条目]。

http://localhost:8080/OData/example.svc/Integers发帖 带有帖子正文:

    <?xml version="1.0" encoding="utf-8" ?>  <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <entry>   <id>http://localhost:8080/OData/example.svc/Integers(100)</id>  
<title type="text" />   
<updated>2011-12-29T10:50:33Z</updated>
<author>   <name />    </author>
<link rel="edit" title="Integers" href="Integers(100)" />  
<category term="example.Integers" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
<content type="application/xml"> 
 <m:properties>  
 <d:EntityId m:type="Edm.Int32">100</d:EntityId>    </m:properties>  
 </content>  
 </entry>

我得到 406 not Acceptable Unknown content type application/xml;charset=UTF-8。 Int 集合内容类型为 application/xml。仍然无法找出为什么会获得此响应。 有谁知道我在这里缺少什么。

提前致谢。

【问题讨论】:

    标签: java odata odata4j


    【解决方案1】:
    1. 使用 application/atom+xml 作为 Content-Type
    2. 条目应该是文档元素(您上面的 xml 格式不正确)

    见:http://www.odata.org/developers/protocols/operations#CreatingnewEntries

    希望对您有所帮助,
    - 约翰

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 2017-07-15
      • 2019-11-17
      • 2017-08-23
      • 1970-01-01
      • 2015-06-21
      相关资源
      最近更新 更多