我使用 Apache Olingo v2。SAP 是服务器,我负责客户端。我尝试用导航实体编写实体。我解释我想说的。有一个名为 HUIDENT 的实体集,该集包含一个名为 ToHuContent 的导航属性。
<EntityType Name="HUIDENT" sap:content-version="1">
<Key>
<PropertyRef Name="Lgnum"/>
<PropertyRef Name="Huident"/>
</Key>
<Property Name="Lgnum" Type="Edm.String" Nullable="false" MaxLength="4" sap:label="Numéro magasin" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Huident" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Unité manutent." sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<NavigationProperty Name="ToHuContent" Relationship="SERVICE_HU_CONTENT_SRV.Assoc_Hu_Content" FromRole="FromRole_Assoc_Hu_Content" ToRole="ToRole_Assoc_Hu_Content"/>
</EntityType>
一个HUCONTENT是
<EntityType Name="HUCONTENT" sap:content-version="1">
<Key>
<PropertyRef Name="Lgnum"/>
<PropertyRef Name="Huident"/>
</Key>
<Property Name="Lgnum" Type="Edm.String" Nullable="false" MaxLength="4" sap:label="Numéro magasin" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Huident" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Unité manutent." sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Matnr" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Produit" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Ean11" Type="Edm.String" Nullable="false" MaxLength="18" sap:label="Code EAN/UPC" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Batchid" Type="Edm.Binary" Nullable="false" sap:label="Lot" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Quan" Type="Edm.Decimal" Nullable="false" Precision="31" Scale="14" sap:unit="Unit" sap:label="Quantité" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Unit" Type="Edm.String" Nullable="false" MaxLength="3" sap:label="Unité" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false" sap:semantics="unit-of-measure"/>
<Property Name="Maktx" Type="Edm.String" Nullable="false" MaxLength="40" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Brand" Type="Edm.String" Nullable="false" MaxLength="4" sap:label="Brand" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<NavigationProperty Name="ToHuIdent" Relationship="SERVICE_HU_CONTENT_SRV.Assoc_Hu_Content" FromRole="ToRole_Assoc_Hu_Content" ToRole="FromRole_Assoc_Hu_Content"/>
</EntityType>
我想发送一个带有一些 HUIDENT 的 HUIDENT,但我不知道该怎么做。我想要这样的饲料
<?xml version="1.0" encoding="utf-8"?>
<entry xml:base="secretUrl" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<id>secretUrl/HUIDENTSet(Lgnum='IN01',Huident='155000000000001757')</id>
<title type="text">HUIDENTSet(Lgnum='IN01',Huident='155000000000001757')</title>
<updated>2016-05-26T22:48:07Z</updated>
<category term="SERVICE.HUIDENT" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="HUIDENTSet(Lgnum='IN01',Huident='155000000000001757')" rel="self" title="HUIDENT"/>
<link href="HUIDENTSet(Lgnum='IN01',Huident='155000000000001757')/ToHuContent" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ToHuContent" type="application/atom+xml;type=feed" title="ToHuContent">
<m:inline>
<feed xml:base="secretUrl/SERVICE/">
<entry>
<content type="application/xml">
<m:properties>
<d:Lgnum>IN01</d:Lgnum>
<d:Huident>155000000000001757</d:Huident>
<d:Epc>12345</d:Epc>
<d:Matnr>1543473</d:Matnr>
<d:Ean>122333</d:Ean>
<d:Expiration_date>2016-05-27T00:00:00</d:Expiration_date>
<d:CRreatedAt>2016-05-26T22:48:00</d:CRreatedAt>
</m:properties>
</content>
</entry>
<entry>
<content type="application/xml">
<m:properties>
<d:Lgnum>IN01</d:Lgnum>
<d:Huident>155000000000001757</d:Huident>
<d:Epc>12345</d:Epc>
<d:RfidStatus/>
<d:Matnr>1543473</d:Matnr>
<d:Expiration_date>2016-05-27T00:00:00</d:Expiration_date>
<d:CRreatedAt>2016-05-26T22:48:00</d:CRreatedAt>
</m:properties>
</content>
</entry>
</feed>
</m:inline>
</link>
<content type="application/xml">
<m:properties>
<d:Lgnum>IN01</d:Lgnum>
<d:Huident>155000000000001757</d:Huident>
</m:properties>
</content>
</entry>
使用 Olingo 我有一些东西
final EntityProviderWriteProperties properties = EntityProviderWriteProperties
.serviceRoot(new URI(this.serviceRoot + "/"))
.build();
final ODataResponse response = EntityProvider.writeEntry("application/xml", entitySet, new ImmutableMap.Builder<String, Object>()
.put("Lgnum", "IN01")
.put("Huident", "1")
.build(), properties);
而且我不知道在哪里可以设置 HUCONTENT 实体。