yhknight / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

odata4j doesn't recognize WCF-$metadata correctly #226

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I created a new project (Empty ASP.NET Web Application) with Visual studio 
2012 und WCF Data Services Tools 5.1
2. I added an ADO.NET Entity Data Model and imported the AdventureWorks 
Database to the model.
3. I added a WCF Data Service 5.1 and exposed the Employee-Table
4. I tried to fetch the Employee-Table with odata4j-client, but it seems like 
the Metadata is not parsed correctly

        reportMetadata(c.getMetadata());
        for(OEntity employee : c.getEntities("Employee").execute()){
            reportEntity("test", employee);
        }

What is the expected output? What do you see instead?
An output of the Metadata, as well as the Employee-Entities.

But there is no output for the metadata at all.

Furthermore, there is an Exception thrown for the getEntities():

at 
org.odata4j.consumer.ConsumerQueryEntitiesRequest.doRequest(ConsumerQueryEntitie
sRequest.java:64)
     at org.odata4j.consumer.ConsumerQueryEntitiesRequest.getEntries(ConsumerQueryEntitiesRequest.java:50)
     at org.odata4j.consumer.ConsumerQueryEntitiesRequest.execute(ConsumerQueryEntitiesRequest.java:40)
     at myapp.net.Synchronisation.getSettings(Synchronisation.java:101)
     at myapp.net.Synchronisation.startSync(Synchronisation.java:72)
     at myapp.net.Synchronisation.run(Synchronisation.java:52)
     at java.lang.Thread.run(Thread.java:856)

What version of the product are you using? On what operating system?
odata4j-0.7.0-clientbundle.jar
Visual Studio 2012, WCF Data Services 5.1

Please provide any additional information below.

The $metadata is :

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" 
xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
  <edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <Schema Namespace="AdventureWorksModel" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
      <EntityType Name="Employee">
        <Key>
          <PropertyRef Name="EmployeeID" />
        </Key>
        <Property Name="EmployeeID" Type="Edm.Int32" Nullable="false" p6:StoreGeneratedPattern="Identity" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation" />
        <Property Name="NationalIDNumber" Type="Edm.String" Nullable="false" MaxLength="15" FixedLength="false" Unicode="true" />
        <Property Name="ContactID" Type="Edm.Int32" Nullable="false" />
        <Property Name="LoginID" Type="Edm.String" Nullable="false" MaxLength="256" FixedLength="false" Unicode="true" />
        <Property Name="ManagerID" Type="Edm.Int32" />
        <Property Name="Title" Type="Edm.String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
        <Property Name="BirthDate" Type="Edm.DateTime" Nullable="false" Precision="3" />
        <Property Name="MaritalStatus" Type="Edm.String" Nullable="false" MaxLength="1" FixedLength="true" Unicode="true" />
        <Property Name="Gender" Type="Edm.String" Nullable="false" MaxLength="1" FixedLength="true" Unicode="true" />
        <Property Name="HireDate" Type="Edm.DateTime" Nullable="false" Precision="3" />
        <Property Name="SalariedFlag" Type="Edm.Boolean" Nullable="false" />
        <Property Name="VacationHours" Type="Edm.Int16" Nullable="false" />
        <Property Name="SickLeaveHours" Type="Edm.Int16" Nullable="false" />
        <Property Name="CurrentFlag" Type="Edm.Boolean" Nullable="false" />
        <Property Name="rowguid" Type="Edm.Guid" Nullable="false" />
        <Property Name="ModifiedDate" Type="Edm.DateTime" Nullable="false" Precision="3" />
        <NavigationProperty Name="Employee1" Relationship="AdventureWorksModel.FK_Employee_Employee_ManagerID" ToRole="Employee1" FromRole="Employee" />
        <NavigationProperty Name="Employee2" Relationship="AdventureWorksModel.FK_Employee_Employee_ManagerID" ToRole="Employee" FromRole="Employee1" />
      </EntityType>
      <Association Name="FK_Employee_Employee_ManagerID">
        <End Type="AdventureWorksModel.Employee" Role="Employee" Multiplicity="0..1" />
        <End Type="AdventureWorksModel.Employee" Role="Employee1" Multiplicity="*" />
        <ReferentialConstraint>
          <Principal Role="Employee">
            <PropertyRef Name="EmployeeID" />
          </Principal>
          <Dependent Role="Employee1">
            <PropertyRef Name="ManagerID" />
          </Dependent>
        </ReferentialConstraint>
      </Association>
    </Schema>
    <Schema Namespace="WebApplication1" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
      <EntityContainer Name="AdventureWorksEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
        <EntitySet Name="Employee" EntityType="AdventureWorksModel.Employee" />
        <AssociationSet Name="FK_Employee_Employee_ManagerID" Association="AdventureWorksModel.FK_Employee_Employee_ManagerID">
          <End Role="Employee" EntitySet="Employee" />
          <End Role="Employee1" EntitySet="Employee" />
        </AssociationSet>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>

Original issue reported on code.google.com by andreas....@gmail.com on 8 Nov 2012 at 7:30

GoogleCodeExporter commented 9 years ago
WCF DS 5.1 by default uses OData V3.

Try setting it to OData V2:

public static void InitializeService(DataServiceConfiguration config)
{
  config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
  ...
}

Original comment by ralf.ha...@gmail.com on 9 Nov 2012 at 2:34

GoogleCodeExporter commented 9 years ago
Able to repro, http://schemas.microsoft.com/ado/2009/11/edm is the problem.  
I'll take a look.

Original comment by john.spurlock on 10 Nov 2012 at 2:46

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 09bfd54271ab.

Original comment by john.spurlock on 10 Nov 2012 at 3:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
How can I get the patch for this issue?

Original comment by mcu...@customerlogic.com.au on 4 Jun 2013 at 11:47