我正在为 OData 服务开发一个 Dotnet 客户端应用程序 (CSharp)。OData 服务 (V4) 使用 Apache 4.2.0 Olingo 库在 Java 中实现。
在客户端,代理类是使用“连接的 OData 服务”创建的。
我正在尝试使用以下代码获取整个 EntitySet:
var ctx = new Container(new Uri(uriString: "http://localhost:8080/odata/PaisService.svc/"));
IEnumerable<Pais> paises = ctx.Paises.Execute();
foreach (Pais pais in paises)
{
Console.WriteLine(pais.Descripcion);
}
当我执行应用程序时,出现以下异常:
Microsoft.OData.Client.DataServiceQueryException was unhandled
HResult=-2146233079
Message=Error al procesar esta solicitud.
Source=Microsoft.OData.Client
StackTrace:
en Microsoft.OData.Client.DataServiceRequest.Execute[TElement]>(DataServiceContext context, QueryComponents queryComponents)
en Microsoft.OData.Client.DataServiceQuery`1.Execute()
en Microsoft.OData.Client.DataServiceQuery`1.GetEnumerator()
en System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
en System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
en TelerikWpfPoC_1.App..ctor() en c:\users\diego.cairone\documents\visual studio 2015\Projects\TelerikWpfPoC-1\TelerikWpfPoC-1\App.xaml.cs:línea 20
en TelerikWpfPoC_1.App.Main() en c:\users\diego.cairone\documents\visual studio 2015\Projects\TelerikWpfPoC-1\TelerikWpfPoC-1\obj\x86\Debug\App.g.cs:línea 0
en System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
en System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
en Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
en System.Threading.ThreadHelper.ThreadStart_Context(Object state)
en System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
en System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
en System.Threading.ThreadHelper.ThreadStart()
InnerException:
HResult=-2146233079
Message=La carga de respuesta no es una carga de respuesta válida. Asegúrese de que el elemento de nivel superior sea un elemento Atom o JSON válido o pertenezca al espacio de nombres 'http://docs.oasis-open.org/odata/ns/data'.
Source=Microsoft.OData.Client
StackTrace:
en Microsoft.OData.Client.Materialization.ODataMaterializer.CreateODataMessageReader(IODataResponseMessage responseMessage, ResponseInfo responseInfo, ODataPayloadKind& payloadKind)
en Microsoft.OData.Client.Materialization.ODataMaterializer.CreateMaterializerForMessage(IODataResponseMessage responseMessage, ResponseInfo responseInfo, Type materializerType, QueryComponents queryComponents, ProjectionPlan plan, ODataPayloadKind payloadKind)
en Microsoft.OData.Client.MaterializeAtom..ctor(ResponseInfo responseInfo, QueryComponents queryComponents, ProjectionPlan plan, IODataResponseMessage responseMessage, ODataPayloadKind payloadKind)
en Microsoft.OData.Client.QueryResult.CreateMaterializer(ProjectionPlan plan, ODataPayloadKind payloadKind)
en Microsoft.OData.Client.QueryResult.ProcessResult[TElement](ProjectionPlan plan)
en Microsoft.OData.Client.DataServiceRequest.Execute[TElement](DataServiceContext context, QueryComponents queryComponents)
InnerException:
我不明白这个错误是什么以及如何解决它。有什么建议么?
谢谢。