I am new to OData/Olingo. I am trying out the tutorial at Olingo (http://olingo.apache.org/doc/odata4/tutorials/read/tutorial_read.html), and have currently completed chapter 2. However, When I tried validating my service through the OData Validator (http://services.odata.org/validation/) it fails stating: Error retrieving validation results
Here is what I get when I hit: /ODataDemo/Service.svc/
<app:service xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:metadata="http://docs.oasis-open.org/odata/ns/metadata" metadata:context="$metadata">
<app:workspace>
<atom:title>NTTD.OData.Container</atom:title>
<app:collection href="Properties">
<atom:title>Properties</atom:title>
</app:collection>
</app:workspace>
</app:service>
Here is the metadata at /ODataDemo/NttdService.svc/$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="NTTD.OData">
<EntityType Name="Property">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.Int32"/>
<Property Name="Name" Type="Edm.String"/>
<Property Name="Location" Type="Edm.String"/>
</EntityType>
<EntityContainer Name="Container">
<EntitySet Name="Properties" EntityType="NTTD.OData.Property"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Please help. Where are things going wrong?
Related
I am trying to run a query similar to
/contacts?$filter=LastModified gt 2022-03-19T12:50:54.219Z
To the following entity:
<EntityType Name="Entity" Abstract="true">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Guid" Nullable="false" />
<Property Name="ConcurrencyToken" Type="Edm.Guid" />
<Property Name="LastModified" Type="Edm.DateTimeOffset" />
</EntityType
The query seems to work but it is not filtering anything for me. I have also tried a lot of alternatives but nothing works. Think this is an issue with the server?
Say, for such an entity defined below, what is the correct response for GET "serviceRoot/entity(1)/nav"? Assuming entity with id 1 has valid values, but its stored key for the 'nav' reference is null.
<EntityType Name="entityType">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Nullable="false" Type="Edm.Integer"/>
<Property Name="name" Nullable="false" Type="Edm.String"/>
<NavigationProperty Name="nav" Nullable="true" Type="this.navType"/>
</EntityType>
<EntityType Name="navType">
<Key>
<PropertyRef Name="navId"/>
</Key>
<Property Name="navId" Nullable="false" Type="Edm.Integer"/>
<Property Name="name" Nullable="false" Type="Edm.String"/>
</EntityType>
<EntityContainer Name="Container">
<EntitySet EntityType="navType" Name="navSet"/>
<EntitySet EntityType="entityType" Name="entity">
<NavigationPropertyBinding Path="nav" Target="this.navSet"/>
</EntitySet>
</EntityContainer>
204 No Content is the correct response according to the OData v4 specification.
If the relationship terminates on a single entity, the response MUST be the format-specific representation of the related single entity. If no entity is related, the service returns 204 No Content.
Source: Requesting Related Entities
Good guess!
I'd like to set my own EntityContainer name other than the default 'Default' viewable in the XML $metadata schema.
I'm aware we can define our own Schema's using the odata-v4-metadata package, but this would mean the metadata would be returned as a JSON file instead of XML. I'm using a proxy generation script on the metadata file which depends on it being returned as XML.
You can see the tags which hold the "Products" EntitySets is called "Default". I'd like to change this if possible, without resorting to using a JSON schema.
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Northwind">
<EntityType Name="Product">
<Key>
<PropertyRef Name="_id"/>
</Key>
<Property Name="_id" Type="Edm.String" Nullable="false">
<Annotation Term="Org.OData.Core.V1.Computed" Bool="true"/>
</Property>
</EntityType>
<EntityContainer Name="Default">
<EntitySet Name="Products" EntityType="Northwind.Product"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Place the following annotation:
#odata.container("MyContainerName")
Above all classes you want to contain under the container "MyContainerName"
I'm trying to binding oData to my List using mock server.
My metadata.xml is
<edmx:Edmx
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"
Version="1.0">
<edmx:DataServices m:DataServiceVersion="2.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="GWSAMPLE_BASIC" xml:lang="en">
<EntityType Name="Equipment" BaseType="GWSAMPLE_BASIC.EquipmentBO">
</EntityType>
<EntityContainer Name="DefaultContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="EquipmentSet" EntityType="GWSAMPLE_BASIC.Equipment"/>
</EntityContainer>
<EntityType Name="EquipmentBO" BaseType="GWSAMPLE_BASIC.BaseEntityBO">
<Property Name="code" Type="Edm.String" Nullable="true"></Property>
</EntityType>
<EntityType Name="BaseEntityBO" Abstract="true">
<Key>
<PropertyRef Name="id"></PropertyRef>
</Key>
<Property Name="id" Type="Edm.String"/>
</EntityType>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Equipment.json:
[
{
"id": "1"
},
{
"id": "2"
},
{
"id": "3"
}
]
But it appear like this:
When I add Key:
<EntityType Name="Equipment" BaseType="GWSAMPLE_BASIC.EquipmentBO">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.String"/>
</EntityType>
It works fine:
Also, I found createKey will also produce an error:
ODataModel-dbg.js:2005 Uncaught TypeError: Cannot read property 'propertyRef' of undefined
this.getModel().createKey("EquipmentSet", {
id : "111"
});
So my question is, can I fix this without changing my oData metadata? Key is already defined in BaseEntityBO.
This question is a duplicate of openui5 issue #951.
Unfortunately datajs, the OData library we are using in SAPUI5, does not support derived entity types. As it is a rarely used feature, there currently are no plans to support this.
It seems this problem can only be solved from backend service.
I have a property of IDictionary type with key type and value type other than string. Most of the examples given on the internet and in Spring.Net uses string as one of the types.
Here are the config settings:
<property name="DirectoryServiceAgents">
<dictionary key-type="OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier, OM.ServiceTier" value-type="OM.ServiceTier.Services.User.Internal.IDirectoryServiceAgent, OM.ServiceTier">
<entry>
<key>
<object type="OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier, OM.ServiceTier">
<constructor-arg type="string" value="${activeDirectory.Domain}"/>
</object>
</key>
<value>
<object type="OM.ServiceTier.Services.User.Internal.DirectoryServiceAgent, OM.ServiceTier">
<property name="LDAPPath" value="${activeDirectory.LDAPPath}"/>
<property name="LDAPContainer" value="${activeDirectory.LDAPContainer}"/>
<property name="UserName" value="${activeDirectory.UserName}"/>
<property name="Password" value="${activeDirectory.Password}"/>
</object>
</value>
</entry>
</dictionary>
</property>
I am getting the following ConfigurationErrorException:
Error creating context 'spring.root': The element 'http://www.springframework.net:value' cannot contain child element 'http://www.springframework.net:object' because the parent element's content model is text only.
Is there something wrong in my config?
I'm not sure if the dictionary configuration supports inline object definitions for keys and/or values. It's not mentioned in the documentation on setting collection values.
Could you try this configuration:
<object>
<!-- snip -->
<property name="DirectoryServiceAgents">
<dictionary
key-type="OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier, OM.ServiceTier"
value-type="OM.ServiceTier.Services.User.Internal.IDirectoryServiceAgent, OM.ServiceTier">
<entry key-ref="authDomainId" value-ref="serviceAgent"/>
</dictionary>
</property>
<!-- snip -->
</object>
<object id="authDomainId"
type="OM.ServiceTier.DTO.Transients.AuthenticationDomainIdentifier, OM.ServiceTier">
<constructor-arg type="string" value="${activeDirectory.Domain}"/>
</object>
<object id="serviceAgent"
type="OM.ServiceTier.Services.User.Internal.DirectoryServiceAgent, OM.ServiceTier">
<property name="LDAPPath" value="${activeDirectory.LDAPPath}"/>
<property name="LDAPContainer" value="${activeDirectory.LDAPContainer}"/>
<property name="UserName" value="${activeDirectory.UserName}"/>
<property name="Password" value="${activeDirectory.Password}"/>
</object>