我大致遵循apache olingo 頁面上的本教程。我想讀取具有復(fù)雜屬性的實(shí)體的集合。設(shè)置提供程序,訪問時(shí)得到以下輸出http://localhost:8080/api/odata/$metadata:<?xml version="1.0" encoding="UTF-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"> <edmx:DataServices> <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="My.Namespace"> <EntityType Name="MyEntity"> <Key> <PropertyRef Name="id"/> </Key> <Property Name="id" Type="Edm.String"></Property> <Property Name="name" Type="Edm.String"></Property> <Property Name="description" Type="Edm.String"></Property> <Property Name="complexProp" Type="My.Namespace.MyComplexType"></Property> </EntityType> <ComplexType Name="MyComplexType"> <Property Name="id" Type="Edm.String"></Property> <Property Name="name" Type="Edm.String"></Property> </ComplexType> <EntityContainer Name="Container"> <EntitySet Name="MyEntities" EntityType="My.Namespace.MyEntity"></EntitySet> </EntityContainer> </Schema> </edmx:DataServices></edmx:Edmx>這對我來說似乎沒問題(是嗎?)。但是當(dāng)我嘗試讀取我的實(shí)體訪問集合時(shí)http://localhost:8080/api/odata/MyEntities,我收到了返回消息Cannot find type with name: My.Namespace.MyComplexType當(dāng)在序列化器上調(diào)用時(shí),單步執(zhí)行代碼會(huì)發(fā)現(xiàn)readEntityCollection處理器方法中拋出了期望。entityCollection我一定錯(cuò)過了一個(gè)重要的觀點(diǎn),因?yàn)樵谖铱磥磉@My.Namespace.MyComplexType是明確定義的。
1 回答

飲歌長嘯
TA貢獻(xiàn)1951條經(jīng)驗(yàn) 獲得超3個(gè)贊
雖然異常是在處理器中拋出的,但該錯(cuò)誤與序列化沒有任何關(guān)系。
MyComplexType
無法找到復(fù)雜類型,因?yàn)?onlygetEntityType(final FullQualifiedName entityTypeName)
在 EdmProvider 中被覆蓋,但沒有被覆蓋getComplexType(final FullQualifiedName complexTypeName)
。olingo
似乎通過調(diào)用這些方法來搜索類型。
重寫此方法后,所有數(shù)據(jù)均正確顯示。
添加回答
舉報(bào)
0/150
提交
取消