You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/04/01 16:18:38 UTC

[11/51] [abbrv] git commit: [OLINGO-212] Reference/Include handling implemented

[OLINGO-212] Reference/Include handling implemented


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/26142187
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/26142187
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/26142187

Branch: refs/heads/master
Commit: 26142187b8840845525b7d13d532746e5b1a1d0c
Parents: 59d54d8
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Mar 27 15:11:15 2014 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Mar 27 15:11:15 2014 +0100

----------------------------------------------------------------------
 .../org/apache/olingo/fit/AbstractServices.java |  12 +-
 .../java/org/apache/olingo/fit/V4NorthWind.java |  46 +++
 .../org/apache/olingo/fit/V4NorthWindExt.java   |  46 +++
 .../main/resources/v4/northwind-metadata.xml    |  91 +++++
 .../main/resources/v4/northwindExt-metadata.xml | 408 +++++++++++++++++++
 .../main/webapp/WEB-INF/applicationContext.xml  |   4 +-
 .../retrieve/CommonRetrieveRequestFactory.java  |  62 +--
 .../request/retrieve/EdmMetadataRequest.java    |  28 ++
 .../request/retrieve/ODataMetadataRequest.java  |  28 --
 .../request/retrieve/XMLMetadataRequest.java    |  29 ++
 .../olingo/client/api/op/CommonODataReader.java |  13 +-
 .../communication/request/ODataRequestImpl.java |   2 +-
 .../retrieve/AbstractMetadataRequestImpl.java   |  52 +++
 .../retrieve/AbstractODataRetrieveRequest.java  |   4 +
 .../AbstractRetrieveRequestFactory.java         |   7 +-
 .../retrieve/EdmMetadataRequestImpl.java        |  73 ++++
 .../retrieve/ODataMetadataRequestImpl.java      | 108 -----
 .../retrieve/v3/RetrieveRequestFactoryImpl.java |   8 +-
 .../retrieve/v3/XMLMetadataRequestImpl.java     |  79 ++++
 .../retrieve/v4/RetrieveRequestFactoryImpl.java |   7 +
 .../retrieve/v4/XMLMetadataRequestImpl.java     | 122 ++++++
 .../edm/AbstractEdmServiceMetadataImpl.java     |  24 +-
 .../olingo/client/core/edm/EdmClientImpl.java   |  46 ++-
 .../client/core/edm/EdmEntityContainerImpl.java |  48 +--
 .../olingo/client/core/edm/EdmSchemaImpl.java   |   9 +-
 .../client/core/edm/v3/EdmEntitySetProxy.java   |  11 +-
 .../core/edm/v3/EdmServiceMetadataImpl.java     |   9 +-
 .../core/edm/v4/EdmServiceMetadataImpl.java     |  24 +-
 .../client/core/edm/xml/v4/XMLMetadataImpl.java |   1 +
 .../client/core/op/AbstractODataReader.java     |  19 +
 .../core/op/impl/v3/ODataDeserializerImpl.java  |   3 +-
 .../client/core/op/impl/v3/ODataReaderImpl.java |  15 -
 .../client/core/op/impl/v4/ODataReaderImpl.java |  16 -
 .../core/it/AbstractMetadataTestITCase.java     |   4 +
 .../client/core/it/v4/MetadataTestITCase.java   |  22 +-
 .../olingo/client/core/v4/MetadataTest.java     |   1 -
 .../olingo/client/core/v4/fromdoc1-metadata.xml |   2 +-
 37 files changed, 1188 insertions(+), 295 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index 1ffba94..e25908f 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -68,9 +68,10 @@ public abstract class AbstractServices {
    */
   protected static final Logger LOG = LoggerFactory.getLogger(AbstractServices.class);
 
-  private static Set<ODataVersion> initialized = EnumSet.noneOf(ODataVersion.class);
+  private static final Set<ODataVersion> INITIALIZED = EnumSet.noneOf(ODataVersion.class);
 
   protected abstract ODataVersion getVersion();
+
   protected final AbstractXMLUtilities xml;
 
   protected final AbstractJSONUtilities json;
@@ -84,9 +85,9 @@ public abstract class AbstractServices {
       this.json = new org.apache.olingo.fit.utils.v4.JSONUtilities();
     }
 
-    if (!initialized.contains(getVersion())) {
+    if (!INITIALIZED.contains(getVersion())) {
       xml.retrieveLinkInfoFromMetadata();
-      initialized.add(getVersion());
+      INITIALIZED.add(getVersion());
     }
   }
 
@@ -136,10 +137,9 @@ public abstract class AbstractServices {
     return getMetadata("large" + StringUtils.capitalize(METADATA));
   }
 
-  private Response getMetadata(final String filename) {
+  protected Response getMetadata(final String filename) {
     try {
-      return xml.
-              createResponse(FSManager.instance(getVersion()).readFile(filename, Accept.XML), null, Accept.XML);
+      return xml.createResponse(FSManager.instance(getVersion()).readFile(filename, Accept.XML), null, Accept.XML);
     } catch (Exception e) {
       return xml.createFaultResponse(Accept.XML.toString(getVersion()), e);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java b/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java
new file mode 100644
index 0000000..5ef82d7
--- /dev/null
+++ b/fit/src/main/java/org/apache/olingo/fit/V4NorthWind.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit;
+
+import org.apache.olingo.fit.utils.ODataVersion;
+import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import org.apache.cxf.interceptor.InInterceptors;
+import static org.apache.olingo.fit.utils.Constants.METADATA;
+
+@Path("/V40/NorthWind.svc")
+@InInterceptors(classes = XHTTPMethodInterceptor.class)
+public class V4NorthWind extends AbstractServices {
+
+  public V4NorthWind() throws Exception {
+    super();
+  }
+
+  @Override
+  protected ODataVersion getVersion() {
+    return ODataVersion.v4;
+  }
+
+  @Override
+  public Response getMetadata() {
+    return getMetadata("northwind-" + METADATA);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java b/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java
new file mode 100644
index 0000000..0dad6ac
--- /dev/null
+++ b/fit/src/main/java/org/apache/olingo/fit/V4NorthWindExt.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.fit;
+
+import org.apache.olingo.fit.utils.ODataVersion;
+import org.apache.olingo.fit.utils.XHTTPMethodInterceptor;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import org.apache.cxf.interceptor.InInterceptors;
+import static org.apache.olingo.fit.utils.Constants.METADATA;
+
+@Path("/V40/NorthWindExt.svc")
+@InInterceptors(classes = XHTTPMethodInterceptor.class)
+public class V4NorthWindExt extends AbstractServices {
+
+  public V4NorthWindExt() throws Exception {
+    super();
+  }
+
+  @Override
+  protected ODataVersion getVersion() {
+    return ODataVersion.v4;
+  }
+
+  @Override
+  public Response getMetadata() {
+    return getMetadata("northwindExt-" + METADATA);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/fit/src/main/resources/v4/northwind-metadata.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/v4/northwind-metadata.xml b/fit/src/main/resources/v4/northwind-metadata.xml
new file mode 100644
index 0000000..85f260f
--- /dev/null
+++ b/fit/src/main/resources/v4/northwind-metadata.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
+  <edmx:Reference Uri="http://localhost:${cargo.servlet.port}/StaticService/V40/NorthWindExt.svc">
+    <edmx:Include Namespace="NorthwindModel"/>
+  </edmx:Reference>
+  <edmx:DataServices>
+    <Schema Namespace="ODataWebExperimental.Northwind.Model" xmlns="http://docs.oasis-open.org/odata/ns/edm">
+      <EntityContainer Name="NorthwindEntities" p4:LazyLoadingEnabled="true" xmlns:p4="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
+        <EntitySet Name="Categories" EntityType="NorthwindModel.Category">
+          <NavigationPropertyBinding Path="Products" Target="Products" />
+        </EntitySet>
+        <EntitySet Name="CustomerDemographics" EntityType="NorthwindModel.CustomerDemographic">
+          <NavigationPropertyBinding Path="Customers" Target="Customers" />
+        </EntitySet>
+        <EntitySet Name="Customers" EntityType="NorthwindModel.Customer">
+          <NavigationPropertyBinding Path="CustomerDemographics" Target="CustomerDemographics" />
+          <NavigationPropertyBinding Path="Orders" Target="Orders" />
+        </EntitySet>
+        <EntitySet Name="Employees" EntityType="NorthwindModel.Employee">
+          <NavigationPropertyBinding Path="Employees1" Target="Employees" />
+          <NavigationPropertyBinding Path="Employee1" Target="Employees" />
+          <NavigationPropertyBinding Path="Orders" Target="Orders" />
+          <NavigationPropertyBinding Path="Territories" Target="Territories" />
+        </EntitySet>
+        <EntitySet Name="Order_Details" EntityType="NorthwindModel.Order_Detail">
+          <NavigationPropertyBinding Path="Order" Target="Orders" />
+          <NavigationPropertyBinding Path="Product" Target="Products" />
+        </EntitySet>
+        <EntitySet Name="Orders" EntityType="NorthwindModel.Order">
+          <NavigationPropertyBinding Path="Customer" Target="Customers" />
+          <NavigationPropertyBinding Path="Employee" Target="Employees" />
+          <NavigationPropertyBinding Path="Order_Details" Target="Order_Details" />
+          <NavigationPropertyBinding Path="Shipper" Target="Shippers" />
+        </EntitySet>
+        <EntitySet Name="Products" EntityType="NorthwindModel.Product">
+          <NavigationPropertyBinding Path="Category" Target="Categories" />
+          <NavigationPropertyBinding Path="Order_Details" Target="Order_Details" />
+          <NavigationPropertyBinding Path="Supplier" Target="Suppliers" />
+        </EntitySet>
+        <EntitySet Name="Regions" EntityType="NorthwindModel.Region">
+          <NavigationPropertyBinding Path="Territories" Target="Territories" />
+        </EntitySet>
+        <EntitySet Name="Shippers" EntityType="NorthwindModel.Shipper">
+          <NavigationPropertyBinding Path="Orders" Target="Orders" />
+        </EntitySet>
+        <EntitySet Name="Suppliers" EntityType="NorthwindModel.Supplier">
+          <NavigationPropertyBinding Path="Products" Target="Products" />
+        </EntitySet>
+        <EntitySet Name="Territories" EntityType="NorthwindModel.Territory">
+          <NavigationPropertyBinding Path="Employees" Target="Employees" />
+          <NavigationPropertyBinding Path="Region" Target="Regions" />
+        </EntitySet>
+        <EntitySet Name="Alphabetical_list_of_products" EntityType="NorthwindModel.Alphabetical_list_of_product" />
+        <EntitySet Name="Category_Sales_for_1997" EntityType="NorthwindModel.Category_Sales_for_1997" />
+        <EntitySet Name="Current_Product_Lists" EntityType="NorthwindModel.Current_Product_List" />
+        <EntitySet Name="Customer_and_Suppliers_by_Cities" EntityType="NorthwindModel.Customer_and_Suppliers_by_City" />
+        <EntitySet Name="Invoices" EntityType="NorthwindModel.Invoice" />
+        <EntitySet Name="Order_Details_Extendeds" EntityType="NorthwindModel.Order_Details_Extended" />
+        <EntitySet Name="Order_Subtotals" EntityType="NorthwindModel.Order_Subtotal" />
+        <EntitySet Name="Orders_Qries" EntityType="NorthwindModel.Orders_Qry" />
+        <EntitySet Name="Product_Sales_for_1997" EntityType="NorthwindModel.Product_Sales_for_1997" />
+        <EntitySet Name="Products_Above_Average_Prices" EntityType="NorthwindModel.Products_Above_Average_Price" />
+        <EntitySet Name="Products_by_Categories" EntityType="NorthwindModel.Products_by_Category" />
+        <EntitySet Name="Sales_by_Categories" EntityType="NorthwindModel.Sales_by_Category" />
+        <EntitySet Name="Sales_Totals_by_Amounts" EntityType="NorthwindModel.Sales_Totals_by_Amount" />
+        <EntitySet Name="Summary_of_Sales_by_Quarters" EntityType="NorthwindModel.Summary_of_Sales_by_Quarter" />
+        <EntitySet Name="Summary_of_Sales_by_Years" EntityType="NorthwindModel.Summary_of_Sales_by_Year" />
+      </EntityContainer>
+    </Schema>
+  </edmx:DataServices>
+</edmx:Edmx>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/fit/src/main/resources/v4/northwindExt-metadata.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/v4/northwindExt-metadata.xml b/fit/src/main/resources/v4/northwindExt-metadata.xml
new file mode 100644
index 0000000..fa1832b
--- /dev/null
+++ b/fit/src/main/resources/v4/northwindExt-metadata.xml
@@ -0,0 +1,408 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
+  <edmx:DataServices>
+    <Schema Namespace="NorthwindModel" xmlns="http://docs.oasis-open.org/odata/ns/edm">
+      <EntityType Name="Category">
+        <Key>
+          <PropertyRef Name="CategoryID" />
+        </Key>
+        <Property Name="CategoryID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
+        <Property Name="Description" Type="Edm.String" MaxLength="max" />
+        <Property Name="Picture" Type="Edm.Binary" MaxLength="max" />
+        <NavigationProperty Name="Products" Type="Collection(NorthwindModel.Product)" Partner="Category" />
+      </EntityType>
+      <EntityType Name="CustomerDemographic">
+        <Key>
+          <PropertyRef Name="CustomerTypeID" />
+        </Key>
+        <Property Name="CustomerTypeID" Type="Edm.String" Nullable="false" MaxLength="10" />
+        <Property Name="CustomerDesc" Type="Edm.String" MaxLength="max" />
+        <NavigationProperty Name="Customers" Type="Collection(NorthwindModel.Customer)" Partner="CustomerDemographics" />
+      </EntityType>
+      <EntityType Name="Customer">
+        <Key>
+          <PropertyRef Name="CustomerID" />
+        </Key>
+        <Property Name="CustomerID" Type="Edm.String" Nullable="false" MaxLength="5" />
+        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="ContactName" Type="Edm.String" MaxLength="30" />
+        <Property Name="ContactTitle" Type="Edm.String" MaxLength="30" />
+        <Property Name="Address" Type="Edm.String" MaxLength="60" />
+        <Property Name="City" Type="Edm.String" MaxLength="15" />
+        <Property Name="Region" Type="Edm.String" MaxLength="15" />
+        <Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="Country" Type="Edm.String" MaxLength="15" />
+        <Property Name="Phone" Type="Edm.String" MaxLength="24" />
+        <Property Name="Fax" Type="Edm.String" MaxLength="24" />
+        <NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Customer" />
+        <NavigationProperty Name="CustomerDemographics" Type="Collection(NorthwindModel.CustomerDemographic)" Partner="Customers" />
+      </EntityType>
+      <EntityType Name="Employee">
+        <Key>
+          <PropertyRef Name="EmployeeID" />
+        </Key>
+        <Property Name="EmployeeID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+        <Property Name="LastName" Type="Edm.String" Nullable="false" MaxLength="20" />
+        <Property Name="FirstName" Type="Edm.String" Nullable="false" MaxLength="10" />
+        <Property Name="Title" Type="Edm.String" MaxLength="30" />
+        <Property Name="TitleOfCourtesy" Type="Edm.String" MaxLength="25" />
+        <Property Name="BirthDate" Type="Edm.DateTimeOffset" />
+        <Property Name="HireDate" Type="Edm.DateTimeOffset" />
+        <Property Name="Address" Type="Edm.String" MaxLength="60" />
+        <Property Name="City" Type="Edm.String" MaxLength="15" />
+        <Property Name="Region" Type="Edm.String" MaxLength="15" />
+        <Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="Country" Type="Edm.String" MaxLength="15" />
+        <Property Name="HomePhone" Type="Edm.String" MaxLength="24" />
+        <Property Name="Extension" Type="Edm.String" MaxLength="4" />
+        <Property Name="Photo" Type="Edm.Binary" MaxLength="max" />
+        <Property Name="Notes" Type="Edm.String" MaxLength="max" />
+        <Property Name="ReportsTo" Type="Edm.Int32" />
+        <Property Name="PhotoPath" Type="Edm.String" MaxLength="255" />
+        <NavigationProperty Name="Employees1" Type="Collection(NorthwindModel.Employee)" Partner="Employee1" />
+        <NavigationProperty Name="Employee1" Type="NorthwindModel.Employee" Partner="Employees1">
+          <ReferentialConstraint Property="ReportsTo" ReferencedProperty="EmployeeID" />
+        </NavigationProperty>
+        <NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Employee" />
+        <NavigationProperty Name="Territories" Type="Collection(NorthwindModel.Territory)" Partner="Employees" />
+      </EntityType>
+      <EntityType Name="Order_Detail">
+        <Key>
+          <PropertyRef Name="OrderID" />
+          <PropertyRef Name="ProductID" />
+        </Key>
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
+        <Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
+        <Property Name="Discount" Type="Edm.Single" Nullable="false" />
+        <NavigationProperty Name="Order" Type="NorthwindModel.Order" Nullable="false" Partner="Order_Details">
+          <ReferentialConstraint Property="OrderID" ReferencedProperty="OrderID" />
+        </NavigationProperty>
+        <NavigationProperty Name="Product" Type="NorthwindModel.Product" Nullable="false" Partner="Order_Details">
+          <ReferentialConstraint Property="ProductID" ReferencedProperty="ProductID" />
+        </NavigationProperty>
+      </EntityType>
+      <EntityType Name="Order">
+        <Key>
+          <PropertyRef Name="OrderID" />
+        </Key>
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+        <Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
+        <Property Name="EmployeeID" Type="Edm.Int32" />
+        <Property Name="OrderDate" Type="Edm.DateTimeOffset" />
+        <Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
+        <Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
+        <Property Name="ShipVia" Type="Edm.Int32" />
+        <Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
+        <Property Name="ShipName" Type="Edm.String" MaxLength="40" />
+        <Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
+        <Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
+        <Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
+        <Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
+        <NavigationProperty Name="Customer" Type="NorthwindModel.Customer" Partner="Orders">
+          <ReferentialConstraint Property="CustomerID" ReferencedProperty="CustomerID" />
+        </NavigationProperty>
+        <NavigationProperty Name="Employee" Type="NorthwindModel.Employee" Partner="Orders">
+          <ReferentialConstraint Property="EmployeeID" ReferencedProperty="EmployeeID" />
+        </NavigationProperty>
+        <NavigationProperty Name="Order_Details" Type="Collection(NorthwindModel.Order_Detail)" Partner="Order" />
+        <NavigationProperty Name="Shipper" Type="NorthwindModel.Shipper" Partner="Orders">
+          <ReferentialConstraint Property="ShipVia" ReferencedProperty="ShipperID" />
+        </NavigationProperty>
+      </EntityType>
+      <EntityType Name="Product">
+        <Key>
+          <PropertyRef Name="ProductID" />
+        </Key>
+        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="SupplierID" Type="Edm.Int32" />
+        <Property Name="CategoryID" Type="Edm.Int32" />
+        <Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
+        <Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
+        <Property Name="UnitsInStock" Type="Edm.Int16" />
+        <Property Name="UnitsOnOrder" Type="Edm.Int16" />
+        <Property Name="ReorderLevel" Type="Edm.Int16" />
+        <Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
+        <NavigationProperty Name="Category" Type="NorthwindModel.Category" Partner="Products">
+          <ReferentialConstraint Property="CategoryID" ReferencedProperty="CategoryID" />
+        </NavigationProperty>
+        <NavigationProperty Name="Order_Details" Type="Collection(NorthwindModel.Order_Detail)" Partner="Product" />
+        <NavigationProperty Name="Supplier" Type="NorthwindModel.Supplier" Partner="Products">
+          <ReferentialConstraint Property="SupplierID" ReferencedProperty="SupplierID" />
+        </NavigationProperty>
+      </EntityType>
+      <EntityType Name="Region">
+        <Key>
+          <PropertyRef Name="RegionID" />
+        </Key>
+        <Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="RegionDescription" Type="Edm.String" Nullable="false" MaxLength="50" />
+        <NavigationProperty Name="Territories" Type="Collection(NorthwindModel.Territory)" Partner="Region" />
+      </EntityType>
+      <EntityType Name="Shipper">
+        <Key>
+          <PropertyRef Name="ShipperID" />
+        </Key>
+        <Property Name="ShipperID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="Phone" Type="Edm.String" MaxLength="24" />
+        <NavigationProperty Name="Orders" Type="Collection(NorthwindModel.Order)" Partner="Shipper" />
+      </EntityType>
+      <EntityType Name="Supplier">
+        <Key>
+          <PropertyRef Name="SupplierID" />
+        </Key>
+        <Property Name="SupplierID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="ContactName" Type="Edm.String" MaxLength="30" />
+        <Property Name="ContactTitle" Type="Edm.String" MaxLength="30" />
+        <Property Name="Address" Type="Edm.String" MaxLength="60" />
+        <Property Name="City" Type="Edm.String" MaxLength="15" />
+        <Property Name="Region" Type="Edm.String" MaxLength="15" />
+        <Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="Country" Type="Edm.String" MaxLength="15" />
+        <Property Name="Phone" Type="Edm.String" MaxLength="24" />
+        <Property Name="Fax" Type="Edm.String" MaxLength="24" />
+        <Property Name="HomePage" Type="Edm.String" MaxLength="max" />
+        <NavigationProperty Name="Products" Type="Collection(NorthwindModel.Product)" Partner="Supplier" />
+      </EntityType>
+      <EntityType Name="Territory">
+        <Key>
+          <PropertyRef Name="TerritoryID" />
+        </Key>
+        <Property Name="TerritoryID" Type="Edm.String" Nullable="false" MaxLength="20" />
+        <Property Name="TerritoryDescription" Type="Edm.String" Nullable="false" MaxLength="50" />
+        <Property Name="RegionID" Type="Edm.Int32" Nullable="false" />
+        <NavigationProperty Name="Region" Type="NorthwindModel.Region" Nullable="false" Partner="Territories">
+          <ReferentialConstraint Property="RegionID" ReferencedProperty="RegionID" />
+        </NavigationProperty>
+        <NavigationProperty Name="Employees" Type="Collection(NorthwindModel.Employee)" Partner="Territories" />
+      </EntityType>
+      <EntityType Name="Alphabetical_list_of_product">
+        <Key>
+          <PropertyRef Name="CategoryName" />
+          <PropertyRef Name="Discontinued" />
+          <PropertyRef Name="ProductID" />
+          <PropertyRef Name="ProductName" />
+        </Key>
+        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="SupplierID" Type="Edm.Int32" />
+        <Property Name="CategoryID" Type="Edm.Int32" />
+        <Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
+        <Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
+        <Property Name="UnitsInStock" Type="Edm.Int16" />
+        <Property Name="UnitsOnOrder" Type="Edm.Int16" />
+        <Property Name="ReorderLevel" Type="Edm.Int16" />
+        <Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
+        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
+      </EntityType>
+      <EntityType Name="Category_Sales_for_1997">
+        <Key>
+          <PropertyRef Name="CategoryName" />
+        </Key>
+        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
+        <Property Name="CategorySales" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Current_Product_List">
+        <Key>
+          <PropertyRef Name="ProductID" />
+          <PropertyRef Name="ProductName" />
+        </Key>
+        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" p5:StoreGeneratedPattern="Identity" xmlns:p5="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+      </EntityType>
+      <EntityType Name="Customer_and_Suppliers_by_City">
+        <Key>
+          <PropertyRef Name="CompanyName" />
+          <PropertyRef Name="Relationship" />
+        </Key>
+        <Property Name="City" Type="Edm.String" MaxLength="15" />
+        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="ContactName" Type="Edm.String" MaxLength="30" />
+        <Property Name="Relationship" Type="Edm.String" Nullable="false" MaxLength="9" Unicode="false" />
+      </EntityType>
+      <EntityType Name="Invoice">
+        <Key>
+          <PropertyRef Name="CustomerName" />
+          <PropertyRef Name="Discount" />
+          <PropertyRef Name="OrderID" />
+          <PropertyRef Name="ProductID" />
+          <PropertyRef Name="ProductName" />
+          <PropertyRef Name="Quantity" />
+          <PropertyRef Name="Salesperson" />
+          <PropertyRef Name="ShipperName" />
+          <PropertyRef Name="UnitPrice" />
+        </Key>
+        <Property Name="ShipName" Type="Edm.String" MaxLength="40" />
+        <Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
+        <Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
+        <Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
+        <Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
+        <Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
+        <Property Name="CustomerName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="Address" Type="Edm.String" MaxLength="60" />
+        <Property Name="City" Type="Edm.String" MaxLength="15" />
+        <Property Name="Region" Type="Edm.String" MaxLength="15" />
+        <Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="Country" Type="Edm.String" MaxLength="15" />
+        <Property Name="Salesperson" Type="Edm.String" Nullable="false" MaxLength="31" />
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="OrderDate" Type="Edm.DateTimeOffset" />
+        <Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
+        <Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
+        <Property Name="ShipperName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
+        <Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
+        <Property Name="Discount" Type="Edm.Single" Nullable="false" />
+        <Property Name="ExtendedPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
+        <Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Order_Details_Extended">
+        <Key>
+          <PropertyRef Name="Discount" />
+          <PropertyRef Name="OrderID" />
+          <PropertyRef Name="ProductID" />
+          <PropertyRef Name="ProductName" />
+          <PropertyRef Name="Quantity" />
+          <PropertyRef Name="UnitPrice" />
+        </Key>
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="ProductID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="UnitPrice" Type="Edm.Decimal" Nullable="false" Precision="19" Scale="4" />
+        <Property Name="Quantity" Type="Edm.Int16" Nullable="false" />
+        <Property Name="Discount" Type="Edm.Single" Nullable="false" />
+        <Property Name="ExtendedPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Order_Subtotal">
+        <Key>
+          <PropertyRef Name="OrderID" />
+        </Key>
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Orders_Qry">
+        <Key>
+          <PropertyRef Name="CompanyName" />
+          <PropertyRef Name="OrderID" />
+        </Key>
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="CustomerID" Type="Edm.String" MaxLength="5" />
+        <Property Name="EmployeeID" Type="Edm.Int32" />
+        <Property Name="OrderDate" Type="Edm.DateTimeOffset" />
+        <Property Name="RequiredDate" Type="Edm.DateTimeOffset" />
+        <Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
+        <Property Name="ShipVia" Type="Edm.Int32" />
+        <Property Name="Freight" Type="Edm.Decimal" Precision="19" Scale="4" />
+        <Property Name="ShipName" Type="Edm.String" MaxLength="40" />
+        <Property Name="ShipAddress" Type="Edm.String" MaxLength="60" />
+        <Property Name="ShipCity" Type="Edm.String" MaxLength="15" />
+        <Property Name="ShipRegion" Type="Edm.String" MaxLength="15" />
+        <Property Name="ShipPostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="ShipCountry" Type="Edm.String" MaxLength="15" />
+        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="Address" Type="Edm.String" MaxLength="60" />
+        <Property Name="City" Type="Edm.String" MaxLength="15" />
+        <Property Name="Region" Type="Edm.String" MaxLength="15" />
+        <Property Name="PostalCode" Type="Edm.String" MaxLength="10" />
+        <Property Name="Country" Type="Edm.String" MaxLength="15" />
+      </EntityType>
+      <EntityType Name="Product_Sales_for_1997">
+        <Key>
+          <PropertyRef Name="CategoryName" />
+          <PropertyRef Name="ProductName" />
+        </Key>
+        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="ProductSales" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Products_Above_Average_Price">
+        <Key>
+          <PropertyRef Name="ProductName" />
+        </Key>
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="UnitPrice" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Products_by_Category">
+        <Key>
+          <PropertyRef Name="CategoryName" />
+          <PropertyRef Name="Discontinued" />
+          <PropertyRef Name="ProductName" />
+        </Key>
+        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="QuantityPerUnit" Type="Edm.String" MaxLength="20" />
+        <Property Name="UnitsInStock" Type="Edm.Int16" />
+        <Property Name="Discontinued" Type="Edm.Boolean" Nullable="false" />
+      </EntityType>
+      <EntityType Name="Sales_by_Category">
+        <Key>
+          <PropertyRef Name="CategoryID" />
+          <PropertyRef Name="CategoryName" />
+          <PropertyRef Name="ProductName" />
+        </Key>
+        <Property Name="CategoryID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="CategoryName" Type="Edm.String" Nullable="false" MaxLength="15" />
+        <Property Name="ProductName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="ProductSales" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Sales_Totals_by_Amount">
+        <Key>
+          <PropertyRef Name="CompanyName" />
+          <PropertyRef Name="OrderID" />
+        </Key>
+        <Property Name="SaleAmount" Type="Edm.Decimal" Precision="19" Scale="4" />
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="CompanyName" Type="Edm.String" Nullable="false" MaxLength="40" />
+        <Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
+      </EntityType>
+      <EntityType Name="Summary_of_Sales_by_Quarter">
+        <Key>
+          <PropertyRef Name="OrderID" />
+        </Key>
+        <Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <EntityType Name="Summary_of_Sales_by_Year">
+        <Key>
+          <PropertyRef Name="OrderID" />
+        </Key>
+        <Property Name="ShippedDate" Type="Edm.DateTimeOffset" />
+        <Property Name="OrderID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Subtotal" Type="Edm.Decimal" Precision="19" Scale="4" />
+      </EntityType>
+      <Annotations Target="ODataWebExperimental.Northwind.Model.NorthwindEntities">
+        <Annotation Term="Com.Microsoft.OData.Service.Conventions.V1.UrlConventions" String="KeyAsSegment" />
+      </Annotations>
+    </Schema>
+  </edmx:DataServices>
+</edmx:Edmx>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/fit/src/main/webapp/WEB-INF/applicationContext.xml
----------------------------------------------------------------------
diff --git a/fit/src/main/webapp/WEB-INF/applicationContext.xml b/fit/src/main/webapp/WEB-INF/applicationContext.xml
index f351ba6..18b555d 100644
--- a/fit/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/fit/src/main/webapp/WEB-INF/applicationContext.xml
@@ -39,8 +39,10 @@
 
   <jaxrs:server id="services" address="/">
     <jaxrs:serviceBeans>
-      <bean class="org.apache.olingo.fit.V4Services"/>
       <bean class="org.apache.olingo.fit.V3Services"/>
+      <bean class="org.apache.olingo.fit.V4Services"/>
+      <bean class="org.apache.olingo.fit.V4NorthWind"/>
+      <bean class="org.apache.olingo.fit.V4NorthWindExt"/>
     </jaxrs:serviceBeans>
     <jaxrs:providers>
       <bean class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
index 89777da..f613cbc 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/CommonRetrieveRequestFactory.java
@@ -27,30 +27,42 @@ import java.net.URI;
 public interface CommonRetrieveRequestFactory extends Serializable {
 
   /**
-   * Gets a service document request instance.
+   * Gets a metadata request instance.
+   * <br/>
+   * Compared to {@link #getMetadataRequest(java.lang.String)}, this method returns a request instance for fetching
+   * low-level metadata representation.
    *
    * @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
    * service.
-   * @return new ODataServiceDocumentRequest instance.
+   * @return new {@link XMLMetadataRequest} instance.
    */
-  ODataServiceDocumentRequest getServiceDocumentRequest(String serviceRoot);
+  XMLMetadataRequest getXMLMetadataRequest(String serviceRoot);
 
   /**
    * Gets a metadata request instance.
    *
    * @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
    * service.
-   * @return new ODataMetadataRequest instance.
+   * @return new {@link EdmMetadataRequest} instance.
+   */
+  EdmMetadataRequest getMetadataRequest(String serviceRoot);
+
+  /**
+   * Gets a service document request instance.
+   *
+   * @param serviceRoot absolute URL (schema, host and port included) representing the location of the root of the data
+   * service.
+   * @return new {@link ODataServiceDocumentRequest} instance.
    */
-  ODataMetadataRequest getMetadataRequest(String serviceRoot);
+  ODataServiceDocumentRequest getServiceDocumentRequest(String serviceRoot);
 
   /**
    * Gets a query request returning a set of one or more OData entities.
    *
-   * @param query query to be performed.
-   * @return new ODataEntitySetRequest instance.
+   * @param uri request URI.
+   * @return new {@link ODataEntitySetRequest} instance.
    */
-  ODataEntitySetRequest getEntitySetRequest(URI query);
+  ODataEntitySetRequest getEntitySetRequest(URI uri);
 
   /**
    * Gets a query request returning a set of one or more OData entities.
@@ -58,48 +70,48 @@ public interface CommonRetrieveRequestFactory extends Serializable {
    * Returned request gives the possibility to consume entities iterating on them without parsing and loading in memory
    * the entire entity set.
    *
-   * @param query query to be performed.
-   * @return new ODataEntitySetIteratorRequest instance.
+   * @param uri request URI.
+   * @return new {@link ODataEntitySetIteratorRequest} instance.
    */
-  ODataEntitySetIteratorRequest getEntitySetIteratorRequest(URI query);
+  ODataEntitySetIteratorRequest getEntitySetIteratorRequest(URI uri);
 
   /**
    * Gets a query request returning a single OData entity.
    *
-   * @param query query to be performed.
-   * @return new ODataEntityRequest instance.
+   * @param uri request URI.
+   * @return new {@link ODataEntityRequest} instance.
    */
-  ODataEntityRequest getEntityRequest(URI query);
+  ODataEntityRequest getEntityRequest(URI uri);
 
   /**
    * Gets a query request returning a single OData entity property.
    *
-   * @param query query to be performed.
-   * @return new ODataPropertyRequest instance.
+   * @param uri request URI.
+   * @return new {@link ODataPropertyRequest} instance.
    */
-  ODataPropertyRequest getPropertyRequest(URI query);
+  ODataPropertyRequest getPropertyRequest(URI uri);
 
   /**
    * Gets a query request returning a single OData entity property value.
    *
-   * @param query query to be performed.
-   * @return new ODataValueRequest instance.
+   * @param uri request URI.
+   * @return new {@link ODataValueRequest} instance.
    */
-  ODataValueRequest getValueRequest(URI query);
+  ODataValueRequest getValueRequest(URI uri);
 
   /**
    * Gets a query request returning a media stream.
    *
-   * @param query query to be performed.
-   * @return new ODataMediaRequest instance.
+   * @param uri request URI.
+   * @return new {@link ODataMediaRequest} instance.
    */
-  ODataMediaRequest getMediaRequest(URI query);
+  ODataMediaRequest getMediaRequest(URI uri);
 
   /**
    * Implements a raw request request without specifying any return type.
    *
-   * @param uri query to be performed.
-   * @return new ODataRawRequest instance.
+   * @param uri request URI.
+   * @return new {@link ODataRawRequest} instance.
    */
   ODataRawRequest getRawRequest(URI uri);
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java
new file mode 100644
index 0000000..d4ea45b
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/EdmMetadataRequest.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.api.communication.request.retrieve;
+
+import org.apache.olingo.commons.api.edm.Edm;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
+/**
+ * This class implements a metadata query request.
+ */
+public interface EdmMetadataRequest extends ODataRetrieveRequest<Edm, ODataFormat> {
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMetadataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMetadataRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMetadataRequest.java
deleted file mode 100644
index 3dcc81b..0000000
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/ODataMetadataRequest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.api.communication.request.retrieve;
-
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.edm.Edm;
-
-/**
- * This class implements a metadata query request.
- */
-public interface ODataMetadataRequest extends ODataRetrieveRequest<Edm, ODataPubFormat> {
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java
new file mode 100644
index 0000000..fbeff8f
--- /dev/null
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/communication/request/retrieve/XMLMetadataRequest.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.api.communication.request.retrieve;
+
+import java.util.List;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
+/**
+ * This class implements an XML metadata request.
+ */
+public interface XMLMetadataRequest extends ODataRetrieveRequest<List<? extends Schema>, ODataFormat> {
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
index 829c5a7..9164918 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/op/CommonODataReader.java
@@ -20,14 +20,16 @@ package org.apache.olingo.client.api.op;
 
 import java.io.InputStream;
 import java.io.Serializable;
+import java.util.List;
+import org.apache.olingo.client.api.edm.xml.Schema;
 import org.apache.olingo.commons.api.domain.ODataError;
 import org.apache.olingo.commons.api.domain.ODataEntity;
 import org.apache.olingo.commons.api.domain.ODataEntitySet;
 import org.apache.olingo.commons.api.domain.ODataProperty;
 import org.apache.olingo.commons.api.domain.ODataServiceDocument;
+import org.apache.olingo.commons.api.edm.Edm;
 import org.apache.olingo.commons.api.format.ODataFormat;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.edm.Edm;
 
 /**
  * OData reader.
@@ -47,6 +49,15 @@ public interface CommonODataReader extends Serializable {
   Edm readMetadata(InputStream input);
 
   /**
+   * Parses a stream into metadata representation, including referenced metadata documents.
+   *
+   * @param xmlSchemas XML representation of the requested metadata document + any other referenced (via
+   * <tt>&lt;edmx:Reference/&gt;</tt>) metadata document
+   * @return metadata representation.
+   */
+  Edm readMetadata(List<? extends Schema> xmlSchemas);
+
+  /**
    * Parses an OData service document.
    *
    * @param input stream to de-serialize.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
index 0a8c495..65cca8d 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/ODataRequestImpl.java
@@ -80,7 +80,7 @@ public class ODataRequestImpl<T extends Format> implements ODataRequest {
 
   protected final CommonODataClient odataClient;
 
-  protected final Class<T> formatRef;
+  private final Class<T> formatRef;
 
   /**
    * OData request method.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java
new file mode 100644
index 0000000..c851b49
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractMetadataRequestImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.communication.request.retrieve;
+
+import java.net.URI;
+import org.apache.http.entity.ContentType;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.communication.request.ODataRequest;
+import org.apache.olingo.commons.api.format.ODataFormat;
+
+public abstract class AbstractMetadataRequestImpl<V> extends AbstractODataRetrieveRequest<V, ODataFormat> {
+
+  public AbstractMetadataRequestImpl(final CommonODataClient odataClient, final URI query) {
+    super(odataClient, ODataFormat.class, query);
+    super.setAccept(ContentType.APPLICATION_XML.getMimeType());
+    super.setContentType(ContentType.APPLICATION_XML.getMimeType());
+  }
+
+  @Override
+  public ODataFormat getDefaultFormat() {
+    return ODataFormat.XML;
+  }
+
+  @Override
+  public ODataRequest setAccept(final String value) {
+    // do nothing: Accept is application/xml
+    return this;
+  }
+
+  @Override
+  public ODataRequest setContentType(final String value) {
+    // do nothing: Content-Type is application/xml
+    return this;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
index 7fd3966..53e46c1 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractODataRetrieveRequest.java
@@ -89,6 +89,10 @@ public abstract class AbstractODataRetrieveRequest<V, T extends Format>
       super(client, res);
     }
 
+    protected HttpResponse getHttpResponse() {
+      return res;
+    }
+
     /**
      * {@inheritDoc }
      */

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
index ddbfd10..3eeabed 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/AbstractRetrieveRequestFactory.java
@@ -25,7 +25,7 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataEntityRe
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetIteratorRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataEntitySetRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataMediaRequest;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataMetadataRequest;
+import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataPropertyRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataRawRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceDocumentRequest;
@@ -78,8 +78,9 @@ public abstract class AbstractRetrieveRequestFactory implements CommonRetrieveRe
   }
 
   @Override
-  public ODataMetadataRequest getMetadataRequest(final String serviceRoot) {
-    return new ODataMetadataRequestImpl(client, client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
+  public EdmMetadataRequest getMetadataRequest(final String serviceRoot) {
+    return new EdmMetadataRequestImpl(client, serviceRoot,
+            client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
new file mode 100644
index 0000000..96df2d6
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.communication.request.retrieve;
+
+import java.net.URI;
+import java.util.List;
+import org.apache.olingo.client.api.CommonODataClient;
+import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.commons.api.edm.Edm;
+
+/**
+ * This class implements a metadata query request.
+ */
+class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements EdmMetadataRequest {
+
+  private final String serviceRoot;
+
+  /**
+   * Constructor.
+   *
+   * @param odataClient client instance getting this request
+   * @param uri metadata URI.
+   */
+  EdmMetadataRequestImpl(final CommonODataClient odataClient, final String serviceRoot, final URI uri) {
+    super(odataClient, uri);
+    this.serviceRoot = serviceRoot;
+  }
+
+  @Override
+  public ODataRetrieveResponse<Edm> execute() {
+    final ODataRetrieveResponse<List<? extends Schema>> xmlMetadataResponse =
+            odataClient.getRetrieveRequestFactory().getXMLMetadataRequest(serviceRoot).execute();
+
+    return new ODataRetrieveResponseImpl() {
+      private Edm metadata = null;
+
+      @Override
+      public void close() {
+        xmlMetadataResponse.close();
+      }
+
+      @Override
+      public Edm getBody() {
+        if (metadata == null) {
+          try {
+            metadata = odataClient.getReader().readMetadata(xmlMetadataResponse.getBody());
+          } finally {
+            this.close();
+          }
+        }
+        return metadata;
+      }
+    };
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java
deleted file mode 100644
index d5ee545..0000000
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/ODataMetadataRequestImpl.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.client.core.communication.request.retrieve;
-
-import java.net.URI;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.entity.ContentType;
-import org.apache.olingo.client.api.CommonODataClient;
-import org.apache.olingo.client.api.communication.request.ODataRequest;
-import org.apache.olingo.client.api.communication.request.retrieve.ODataMetadataRequest;
-import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
-import org.apache.olingo.commons.api.format.ODataPubFormat;
-import org.apache.olingo.commons.api.edm.Edm;
-
-/**
- * This class implements a metadata query request.
- */
-class ODataMetadataRequestImpl extends AbstractODataRetrieveRequest<Edm, ODataPubFormat>
-        implements ODataMetadataRequest {
-
-  /**
-   * Constructor.
-   *
-   * @param odataClient client instance getting this request
-   * @param uri metadata URI.
-   */
-  ODataMetadataRequestImpl(final CommonODataClient odataClient, final URI uri) {
-    super(odataClient, ODataPubFormat.class, uri);
-    super.setAccept(ContentType.APPLICATION_XML.getMimeType());
-    super.setContentType(ContentType.APPLICATION_XML.getMimeType());
-  }
-
-  @Override
-  public ODataRequest setAccept(final String value) {
-    // do nothing: Accept is application/XML
-    return this;
-  }
-
-  @Override
-  public ODataRequest setContentType(final String value) {
-    // do nothing: Accept is application/XML
-    return this;
-  }
-
-  @Override
-  public ODataRetrieveResponse<Edm> execute() {
-    final HttpResponse res = doExecute();
-    return new ODataMetadataResponseImpl(httpClient, res);
-  }
-
-  /**
-   * Response class about an ODataMetadataRequest.
-   */
-  protected class ODataMetadataResponseImpl extends ODataRetrieveResponseImpl {
-
-    private Edm metadata = null;
-
-    /**
-     * Constructor.
-     * <p>
-     * Just to create response templates to be initialized from batch.
-     */
-    public ODataMetadataResponseImpl() {
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param client HTTP client.
-     * @param res HTTP response.
-     */
-    private ODataMetadataResponseImpl(final HttpClient client, final HttpResponse res) {
-      super(client, res);
-    }
-
-    /**
-     * {@inheritDoc }
-     */
-    @Override
-    public Edm getBody() {
-      if (metadata == null) {
-        try {
-          metadata = odataClient.getReader().readMetadata(getRawResponse());
-        } finally {
-          this.close();
-        }
-      }
-      return metadata;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
index 3e07579..f6ba5c1 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/RetrieveRequestFactoryImpl.java
@@ -18,8 +18,8 @@
  */
 package org.apache.olingo.client.core.communication.request.retrieve.v3;
 
-import org.apache.olingo.client.core.communication.request.retrieve.v3.ODataLinkCollectionRequestImpl;
 import java.net.URI;
+import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
 import org.apache.olingo.client.api.v3.ODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.v3.ODataLinkCollectionRequest;
 import org.apache.olingo.client.api.communication.request.retrieve.v3.RetrieveRequestFactory;
@@ -35,6 +35,12 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
   }
 
   @Override
+  public XMLMetadataRequest getXMLMetadataRequest(final String serviceRoot) {
+    return new XMLMetadataRequestImpl(((ODataClient) client),
+            client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
+  }
+
+  @Override
   public ODataLinkCollectionRequest getLinkCollectionRequest(final URI targetURI, final String linkName) {
     return new ODataLinkCollectionRequestImpl((ODataClient) client, targetURI, linkName);
   }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java
new file mode 100644
index 0000000..cf1be41
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v3/XMLMetadataRequestImpl.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.communication.request.retrieve.v3;
+
+import java.net.URI;
+import java.util.List;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.client.api.edm.xml.XMLMetadata;
+import org.apache.olingo.client.api.v3.ODataClient;
+import org.apache.olingo.client.core.communication.request.retrieve.AbstractMetadataRequestImpl;
+
+public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<List<? extends Schema>>
+        implements XMLMetadataRequest {
+
+  XMLMetadataRequestImpl(final ODataClient odataClient, final URI query) {
+    super(odataClient, query);
+  }
+
+  @Override
+  public ODataRetrieveResponse<List<? extends Schema>> execute() {
+    return new XMLMetadataResponseImpl(httpClient, doExecute());
+  }
+
+  public class XMLMetadataResponseImpl extends ODataRetrieveResponseImpl {
+
+    private XMLMetadata metadata = null;
+
+    /**
+     * Constructor.
+     * <br/>
+     * Just to create response templates to be initialized from batch.
+     */
+    private XMLMetadataResponseImpl() {
+      super();
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param client HTTP client.
+     * @param res HTTP response.
+     */
+    private XMLMetadataResponseImpl(final HttpClient client, final HttpResponse res) {
+      super(client, res);
+    }
+
+    @Override
+    public List<? extends Schema> getBody() {
+      if (metadata == null) {
+        try {
+          metadata = odataClient.getDeserializer().toMetadata(getRawResponse());
+        } finally {
+          this.close();
+        }
+      }
+      return metadata.getSchemas();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
index 016320f..69f6f2a 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/RetrieveRequestFactoryImpl.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.client.core.communication.request.retrieve.v4;
 
+import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
 import org.apache.olingo.client.api.v4.ODataClient;
 import org.apache.olingo.client.api.communication.request.retrieve.v4.RetrieveRequestFactory;
 import org.apache.olingo.client.core.communication.request.retrieve.AbstractRetrieveRequestFactory;
@@ -30,4 +31,10 @@ public class RetrieveRequestFactoryImpl extends AbstractRetrieveRequestFactory
   public RetrieveRequestFactoryImpl(final ODataClient client) {
     super(client);
   }
+
+  @Override
+  public XMLMetadataRequest getXMLMetadataRequest(final String serviceRoot) {
+    return new XMLMetadataRequestImpl(((ODataClient) client),
+            client.getURIBuilder(serviceRoot).appendMetadataSegment().build());
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
new file mode 100644
index 0000000..db141eb
--- /dev/null
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/v4/XMLMetadataRequestImpl.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.client.core.communication.request.retrieve.v4;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
+import org.apache.olingo.client.api.communication.response.ODataRetrieveResponse;
+import org.apache.olingo.client.api.edm.xml.Schema;
+import org.apache.olingo.client.api.edm.xml.v4.Include;
+import org.apache.olingo.client.api.edm.xml.v4.Reference;
+import org.apache.olingo.client.api.edm.xml.v4.XMLMetadata;
+import org.apache.olingo.client.api.v4.ODataClient;
+import org.apache.olingo.client.core.communication.request.retrieve.AbstractMetadataRequestImpl;
+
+public class XMLMetadataRequestImpl extends AbstractMetadataRequestImpl<List<? extends Schema>>
+        implements XMLMetadataRequest {
+
+  XMLMetadataRequestImpl(final ODataClient odataClient, final URI uri) {
+    super(odataClient, uri);
+  }
+
+  @Override
+  public ODataRetrieveResponse<List<? extends Schema>> execute() {
+    final SingleXMLMetadatRequestImpl rootReq = new SingleXMLMetadatRequestImpl((ODataClient) odataClient, uri);
+    final ODataRetrieveResponse<XMLMetadata> rootRes = rootReq.execute();
+
+    final XMLMetadataResponseImpl response = new XMLMetadataResponseImpl();
+
+    final XMLMetadata rootMetadata = rootRes.getBody();
+    response.getSchemas().addAll(rootMetadata.getSchemas());
+
+    if (!rootMetadata.getReferences().isEmpty()) {
+      for (Reference reference : rootMetadata.getReferences()) {
+        final SingleXMLMetadatRequestImpl includeReq = new SingleXMLMetadatRequestImpl((ODataClient) odataClient,
+                odataClient.getURIBuilder(reference.getUri().toASCIIString()).appendMetadataSegment().build());
+        final XMLMetadata includeMetadata = includeReq.execute().getBody();
+        
+        for (Include include : reference.getIncludes()) {
+          Schema includedSchema = includeMetadata.getSchema(include.getNamespace());
+          if (includedSchema == null && StringUtils.isNotBlank(include.getAlias())) {
+            includedSchema = includeMetadata.getSchema(include.getAlias());
+          }
+          if (includedSchema != null) {
+            response.getSchemas().add(includedSchema);
+          }
+        }
+      }
+    }
+
+    return response;
+  }
+
+  private class SingleXMLMetadatRequestImpl extends AbstractMetadataRequestImpl<XMLMetadata> {
+
+    public SingleXMLMetadatRequestImpl(final ODataClient odataClient, final URI uri) {
+      super(odataClient, uri);
+    }
+
+    @Override
+    public ODataRetrieveResponse<XMLMetadata> execute() {
+      return new ODataRetrieveResponseImpl(httpClient, doExecute()) {
+
+        @Override
+        public XMLMetadata getBody() {
+          try {
+            return ((ODataClient) odataClient).getDeserializer().toMetadata(getRawResponse());
+          } finally {
+            this.close();
+          }
+        }
+      };
+    }
+  }
+
+  public class XMLMetadataResponseImpl extends ODataRetrieveResponseImpl {
+
+    private final List<Schema> schemas = new ArrayList<Schema>();
+
+    /**
+     * Constructor.
+     * <br/>
+     * Just to create response templates to be initialized from batch.
+     */
+    private XMLMetadataResponseImpl() {
+      super();
+    }
+
+    @Override
+    public void close() {
+      // just do nothing, this is a placeholder response
+    }
+
+    public List<Schema> getSchemas() {
+      return schemas;
+    }
+
+    @Override
+    public List<? extends Schema> getBody() {
+      return getSchemas();
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/26142187/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
index 6508224..12463d3 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/edm/AbstractEdmServiceMetadataImpl.java
@@ -29,16 +29,16 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.olingo.client.api.edm.xml.EntityContainer;
 import org.apache.olingo.client.api.edm.xml.EntitySet;
 import org.apache.olingo.client.api.edm.xml.Schema;
-import org.apache.olingo.client.api.edm.xml.XMLMetadata;
 import org.apache.olingo.commons.api.edm.EdmActionImportInfo;
 import org.apache.olingo.commons.api.edm.EdmEntitySetInfo;
 import org.apache.olingo.commons.api.edm.EdmFunctionImportInfo;
 import org.apache.olingo.commons.api.edm.EdmServiceMetadata;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
 import org.apache.olingo.commons.core.edm.EdmEntitySetInfoImpl;
 
 public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetadata {
 
-  protected final XMLMetadata xmlMetadata;
+  protected final List<? extends Schema> xmlSchemas;
 
   private List<EdmEntitySetInfo> entitySetInfos;
 
@@ -46,17 +46,16 @@ public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetada
 
   protected List<EdmActionImportInfo> actionImportInfos;
 
-  public static EdmServiceMetadata getInstance(final XMLMetadata xmlMetadata) {
-    return xmlMetadata instanceof org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl
-            ? new org.apache.olingo.client.core.edm.v3.EdmServiceMetadataImpl(
-                    (org.apache.olingo.client.core.edm.xml.v3.XMLMetadataImpl) xmlMetadata)
-            : new org.apache.olingo.client.core.edm.v4.EdmServiceMetadataImpl(
-                    (org.apache.olingo.client.core.edm.xml.v4.XMLMetadataImpl) xmlMetadata);
+  public static EdmServiceMetadata getInstance(final ODataServiceVersion version,
+          final List<? extends Schema> xmlSchemas) {
 
+    return version == ODataServiceVersion.V30
+            ? new org.apache.olingo.client.core.edm.v3.EdmServiceMetadataImpl(xmlSchemas)
+            : new org.apache.olingo.client.core.edm.v4.EdmServiceMetadataImpl(xmlSchemas);
   }
 
-  public AbstractEdmServiceMetadataImpl(final XMLMetadata xmlMetadata) {
-    this.xmlMetadata = xmlMetadata;
+  public AbstractEdmServiceMetadataImpl(final List<? extends Schema> xmlSchemas) {
+    this.xmlSchemas = xmlSchemas;
   }
 
   @Override
@@ -69,11 +68,10 @@ public abstract class AbstractEdmServiceMetadataImpl implements EdmServiceMetada
     synchronized (this) {
       if (entitySetInfos == null) {
         entitySetInfos = new ArrayList<EdmEntitySetInfo>();
-        for (Schema schema : xmlMetadata.getSchemas()) {
+        for (Schema schema : xmlSchemas) {
           for (EntityContainer entityContainer : schema.getEntityContainers()) {
             for (EntitySet entitySet : entityContainer.getEntitySets()) {
-              entitySetInfos.add(
-                      new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
+              entitySetInfos.add(new EdmEntitySetInfoImpl(entityContainer.getName(), entitySet.getName()));
             }
           }
         }