我大致遵循apache olingo 頁面上的本教程。我想讀取具有復雜屬性的實體的集合。設置提供程序,訪問時得到以下輸出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>這對我來說似乎沒問題(是嗎?)。但是當我嘗試讀取我的實體訪問集合時http://localhost:8080/api/odata/MyEntities,我收到了返回消息Cannot find type with name: My.Namespace.MyComplexType當在序列化器上調用時,單步執行代碼會發現readEntityCollection處理器方法中拋出了期望。entityCollection我一定錯過了一個重要的觀點,因為在我看來這My.Namespace.MyComplexType是明確定義的。
1 回答

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