2015年4月版的Excel Power Query宣傳OData v4兼容性。然而,當我嘗試連接到使用Web API(Microsoft.Data.OData.5.6.0
,Microsoft.AspNet.WebApi.OData.5.5.1
,Microsoft.OData.Core.6.10.0
),我得到一個使用Excel Power Query無法連接到OData v4服務:無效的元數據?
DataSource.Error: OData: The feed's metadata document appears to be invalid.
我是唯一一個寫我的OData v4的服務?有沒有一種方法來調試呢?
這裏的元數據文件:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
<Schema Namespace="MyCompany.Api.OData" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityType Name="Position" OpenType="true">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<Property Name="PositionId" Type="Edm.String" />
<Property Name="Description" Type="Edm.String" />
<Property Name="StartDate" Type="Edm.Date" />
<Property Name="Status" Type="MyCompany.Positions.ValidationStatus" Nullable="false" />
<Property Name="InstrumentTypeId" Type="Edm.Guid" Nullable="false" />
</EntityType>
<EntityType Name="Feed">
<Key>
<PropertyRef Name="Name" />
</Key>
<Property Name="Name" Type="Edm.String" Nullable="false" />
<NavigationProperty Name="Deliveries" Type="Collection(MyCompany.Api.OData.Delivery)" />
</EntityType>
<EntityType Name="Delivery">
<Key>
<PropertyRef Name="ReferenceDate" />
</Key>
<Property Name="ReferenceDate" Type="Edm.DateTimeOffset" Nullable="false" />
<NavigationProperty Name="Positions" Type="Collection(MyCompany.Api.OData.Position)" />
</EntityType>
</Schema>
<Schema Namespace="MyCompany.Positions" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EnumType Name="ValidationStatus">
<Member Name="Invalid" Value="0" />
<Member Name="Valid" Value="1" />
<Member Name="Expired" Value="2" />
</EnumType>
</Schema>
<Schema Namespace="Default" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<EntityContainer Name="Container">
<EntitySet Name="Positions" EntityType="MyCompany.Api.OData.Position" />
<EntitySet Name="Feeds" EntityType="MyCompany.Api.OData.Feed">
<NavigationPropertyBinding Path="Deliveries" Target="Deliveries" />
</EntitySet>
<EntitySet Name="Deliveries" EntityType="MyCompany.Api.OData.Delivery">
<NavigationPropertyBinding Path="Positions" Target="Positions" />
</EntitySet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
編輯
下選項,使在電源查詢絲帶診斷後,我看到下面的警告:
DataMashup.Trace Warning: 24579 : {"Start":"2015-05-26T18:26:53.5539195Z","Action":"Engine/IO/OData/Create","ServiceUri":"http://localhost:54026/.../odata/v4","RequestUrl":"http://localhost:54026/.../odata/v4","RequestHeaders":"null","Exception":"Exception:\r\nExceptionType: Microsoft.Mashup.Engine1.Runtime.ValueException, Microsoft.Mashup.Engine.1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nMessage: [DataSource.Error] OData: The feed's metadata document appears to be invalid.\r\nStackTrace:\n at Microsoft.Mashup.Engine1.Library.OData.EdmModelProcessorBase`1.Build()\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.ODataEnvironment.Create(ServiceDocumentWrapper serviceDoc, Uri metadataUri, Value headers, String resourceKind, ResourceCredentialCollection credentials, IEngineHost host, ODataSettings settings, ODataUserSettings userSettings, Boolean useCachedCredentials)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.ODataResponse.Create(Uri requestUri, HttpResponseData responseData, String resourceKind, Value headers, ResourceCredentialCollection credentials, IEngineHost host, ODataSettings settings, ODataUserSettings userSettings)\r\n at Microsoft.Mashup.Engine1.Library.OData.ODataModule.GetFeed(String resourceKind, TextValue serviceUriValue, TextValue uriValue, Value headers, IEngineHost host, ResourceCredentialCollection credentials, ODataSettingsBase settings, ODataUserSettings userSettings, Boolean useCachedCredentials)\r\n\r\nInnerException\r\nException:\r\nExceptionType: System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\r\nMessage: Operation is not valid due to the current state of the object.\r\nStackTrace:\n at Microsoft.Mashup.Engine1.Library.OData.V4.ODataTypeServices.GetTypeValueFromEdm(EdmPrimitiveTypeKind typeKind)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetTypeValue(IEdmType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetOrCreateTypeValue(Stack`1 processingTypes, IEdmType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetOrCreatePropertyTypeValue(Stack`1 processingTypes, IEdmProperty property)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.CreateRecordTypeValue(Stack`1 processingTypes, IEdmStructuredType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetOrCreateTypeValue(Stack`1 processingTypes, IEdmType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.ProcessTypes()\r\n at Microsoft.Mashup.Engine1.Library.OData.EdmModelProcessorBase`1.Build()\r\n\r\n\r\n\r\n\r\n","ProductVersion":"2.22.4007.242 (Release-V2-Public)","ActivityId":"22edde60-34b3-49eb-8dda-75507d00be29","Process":"Microsoft.Mashup.Container.NetFX40","Pid":6244,"Tid":1,"Duration":"00:00:00.2893059"}
DataMashup.Trace Warning: 24579 : {"Start":"2015-05-26T18:26:53.8596010Z","Action":"SimpleDocumentEvaluator/BeginGetResult<IPreviewValueSource>/callback","Exception":"Exception:\r\nExceptionType: Microsoft.Mashup.Engine1.Runtime.ValueException, Microsoft.Mashup.Engine.1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nMessage: [DataSource.Error] OData: The feed's metadata document appears to be invalid.\r\nStackTrace:\n at Microsoft.Mashup.Evaluator.Interface.EvaluationResult2`1.get_Result()\r\n at Microsoft.Mashup.Evaluator.SimpleDocumentEvaluator.<>c__DisplayClass1.<BeginGetResult>b__0(EvaluationResult2`1 result)\r\n\r\nInnerException\r\nException:\r\nExceptionType: System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\r\nMessage: Operation is not valid due to the current state of the object.\r\nStackTrace:\n at Microsoft.Mashup.Engine1.Library.OData.V4.ODataTypeServices.GetTypeValueFromEdm(EdmPrimitiveTypeKind typeKind)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetTypeValue(IEdmType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetOrCreateTypeValue(Stack`1 processingTypes, IEdmType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetOrCreatePropertyTypeValue(Stack`1 processingTypes, IEdmProperty property)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.CreateRecordTypeValue(Stack`1 processingTypes, IEdmStructuredType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.GetOrCreateTypeValue(Stack`1 processingTypes, IEdmType type)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.EdmModelProcessor.ProcessTypes()\r\n at Microsoft.Mashup.Engine1.Library.OData.EdmModelProcessorBase`1.Build()\r\n\r\n\r\n\r\n\r\n","ProductVersion":"2.22.4007.242 (Release-V2-Public)","ActivityId":"22edde60-34b3-49eb-8dda-75507d00be29","Process":"Microsoft.Mashup.Container.NetFX40","Pid":6244,"Tid":1,"Duration":"00:00:00.0040547"}
DataMashup.Trace Warning: 24579 : {"Start":"2015-05-26T18:26:53.2420994Z","Action":"SimpleDocumentEvaluator/BeginGetResult<IValue>","Exception":"Exception:\r\nExceptionType: Microsoft.Mashup.Engine1.Runtime.ValueException, Microsoft.Mashup.Engine.1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nMessage: [DataSource.Error] OData: The feed's metadata document appears to be invalid.\r\nStackTrace:\n at Microsoft.Mashup.Engine1.Library.OData.EdmModelProcessorBase`1.Build()\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.ODataEnvironment.Create(ServiceDocumentWrapper serviceDoc, Uri metadataUri, Value headers, String resourceKind, ResourceCredentialCollection credentials, IEngineHost host, ODataSettings settings, ODataUserSettings userSettings, Boolean useCachedCredentials)\r\n at Microsoft.Mashup.Engine1.Library.OData.V4.ODataResponse.Create(Uri requestUri, HttpResponseData responseData, String resourceKind, Value headers, ResourceCredentialCollection credentials, IEngineHost host, ODataSettings settings, ODataUserSettings userSettings)\r\n at Microsoft.Mashup.Engine1.Library.OData.ODataModule.GetFeed(String resourceKind, TextValue serviceUriValue, TextValue uriValue, Value headers, IEngineHost host, ResourceCredentialCollection credentials, ODataSettingsBase settings, ODataUserSettings userSettings, Boolean useCachedCredentials)\r\n at Microsoft.Mashup.Engine1.Library.OData.ODataModule.GetFeed(String resourceKind, TextValue serviceUri, Value headers, Value options, IEngineHost host, Boolean isPrivileged)\r\n at Microsoft.Mashup.Engine1.Library.OData.ODataModule.FeedFunctionValue.TypedInvoke(TextValue serviceUri, Value headers, Value options)\r\n at Microsoft.Mashup.Engine1.Runtime.NativeFunctionValue3`4.Invoke(Value arg0, Value arg1, Value arg2)\r\n at Microsoft.Mashup.Engine1.Runtime.NativeFunctionValue3`4.Invoke(Value arg0)\r\n at Microsoft.Mashup.Engine1.Runtime.FunctionValue.MetaTypeFunctionValue.Invoke(Value arg0)\r\n at Microsoft.Mashup.Engine1.Runtime.SerializationApplyingModule.SerializableFunctionValue.Invoke(Value arg0)\r\n at Microsoft.Mashup.Engine1.Language.FunctionInvocationExpression1.Execute(Value frame)\r\n at Microsoft.Mashup.Engine1.Language.DebugExpression.Execute(Value frame)\r\n at Microsoft.Mashup.Engine1.Language.FunctionInvocationExpression2.Execute(Value frame)\r\n at Microsoft.Mashup.Engine1.Language.DebugExpression.Execute(Value frame)\r\n at Microsoft.Mashup.Engine1.Language.RuntimeFunctionValue1.Invoke(Value arg0)\r\n at Microsoft.Mashup.Engine1.Language.RecordExpression.RuntimeRecordValue.Force(Int32 index)\r\n at Microsoft.Mashup.Engine1.Language.RecordExpression.RuntimeRecordValue.get_Item(Int32 index)\r\n at Microsoft.Mashup.Engine1.Runtime.RecordValue.get_Item(String field)\r\n at Microsoft.Mashup.Engine1.Language.FieldAccessExpression.Execute(Value frame)\r\n at Microsoft.Mashup.Engine1.Language.RuntimeFunctionValue1.Invoke(Value arg0)\r\n at Microsoft.Mashup.Engine1.Language.RecordExpression.RuntimeRecordValue.Force(Int32 index)\r\n at Microsoft.Mashup.Engine1.Language.RecordExpression.RuntimeRecordValue.get_Item(Int32 index)\r\n at Microsoft.Mashup.Engine1.Runtime.RecordValue.get_Item(Value key)\r\n at Microsoft.Mashup.Engine1.Runtime.Library.Linker.BindFunctionValue.TypedInvoke(RecordValue environment, Value section, TextValue name)\r\n at Microsoft.Mashup.Engine1.Runtime.NativeFunctionValue3`4.Invoke(Value arg0, Value arg1, Value arg2)\r\n at Microsoft.Mashup.Engine1.Runtime.FunctionValue.Invoke(Value[] args)\r\n at Microsoft.Mashup.Engine1.Language.ExpressionInvocationExpression.Execute(MembersFrame0& frame)\r\n at Microsoft.Mashup.Engine1.Language.MembersFunctionValue0.Invoke()\r\n at Microsoft.Mashup.Engine1.Language.ListExpression.RuntimeListValue.Force(Int32 index)\r\n at Microsoft.Mashup.Engine1.Language.ListExpression.RuntimeListValue.get_Item(Int32 index)\r\n at Microsoft.Mashup.Engine1.Runtime.ListValue.get_Item(Value key)\r\n at Microsoft.Mashup.Engine1.Runtime.Library.List.ElementWithListCheckFunctionValue.Invoke(Value collection, Value key)\r\n at Microsoft.Mashup.Engine1.Language.FunctionInvocationExpression2.Execute(MembersFrame1& frame)\r\n at Microsoft.Mashup.Engine1.Language.MembersFunctionV","ProductVersion":"2.22.4007.242 (Release-V2-Public)","ActivityId":"22edde60-34b3-49eb-8dda-75507d00be29","Process":"Microsoft.Mashup.Container.NetFX40","Pid":6244,"Tid":1,"Duration":"00:00:00.6215902"}
不幸的是,我沒有看到任何特定於我們的OData API的錯誤。
不幸的是,它是非公開的,並且在一定程度上包含敏感數據。但它確實在瀏覽器中加載。我會更新我的問題,以包含剝離的元數據XML(我希望,我不會通過刪除敏感部分破壞任何東西...... :) – Dejan
我不能僅僅從元數據中知道,它可能是解析它在OData失敗。那麼如何開啓跟蹤,查看日誌並告訴我是否在那裏看到任何OData特定的錯誤,或者與我私下共享日誌? –
要啓用跟蹤:Power Query功能區 - >選項 - >啓用電源查詢跟蹤複選框 –