Interacting with a Page Web Service (OData v4) Error
-
That was the point. Inspect the "var" using the debugger before performing the "ToList" and see what you're getting versus what you're expecting.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
The object returned is :
Microsoft.OData.Client.DataServiceQuery(Of Customer_Card)
The object created by the Client generator. I need to call .Execute or something else with collection to make it execute the query. If I do that I get :
Microsoft.OData.Client.QueryOperationResponse(Of Customer\_Card)
The execution seem ok. Problem is when I start enumerating through the list that shold have been produced. I can clearly see in fiddler that result comming back to me is ok. Something is happening on clientside. Maybe the call itself to the service is doing something wierd. But why should it do that when it works on the query for Company. Can this has to do with child/relations spec maybe? Thanks ZD
-
The object returned is :
Microsoft.OData.Client.DataServiceQuery(Of Customer_Card)
The object created by the Client generator. I need to call .Execute or something else with collection to make it execute the query. If I do that I get :
Microsoft.OData.Client.QueryOperationResponse(Of Customer\_Card)
The execution seem ok. Problem is when I start enumerating through the list that shold have been produced. I can clearly see in fiddler that result comming back to me is ok. Something is happening on clientside. Maybe the call itself to the service is doing something wierd. But why should it do that when it works on the query for Company. Can this has to do with child/relations spec maybe? Thanks ZD
You say execution "seems ok" .... Hardly a show of confidence. Instead of assuming it is "ok", there are a number of properties in the response you should look at (e.g. "Error") to confirm that everything is as it should be. [QueryOperationResponse Class (System.Data.Services.Client)](https://msdn.microsoft.com/en-us/library/system.data.services.client.queryoperationresponse(v=vs.113).aspx)
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
You say execution "seems ok" .... Hardly a show of confidence. Instead of assuming it is "ok", there are a number of properties in the response you should look at (e.g. "Error") to confirm that everything is as it should be. [QueryOperationResponse Class (System.Data.Services.Client)](https://msdn.microsoft.com/en-us/library/system.data.services.client.queryoperationresponse(v=vs.113).aspx)
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
Trying executing .Execute on the object of type :
Global.Microsoft.OData.Client.DataServiceQuery(Of Customer_Card)
Gives me this object and I can see in fiddler that response is received and correct but accoring to error TotalCount is missing: https://postimg.org/image/eyv1hglnj/ However I got the objext I am supposed to. If I try to call .ToList it first makes call to .Execute and then try to create :
System.Collections.Generic.List(Of NAVEntities.Customer_Card)
But it produces an error and I the object looking like this: https://postimg.org/image/e3ewt9b5j/ Full stacktrace is:
Microsoft.OData.Core.ODataException was unhandled
HResult=-2146233079
Message=When writing a JSON response, a user model must be specified and the entity set and entity type must be passed to the ODataMessageWriter.CreateODataEntryWriter method or the
ODataFeedAndEntrySerializationInfo must be set on the ODataEntry or ODataFeed that is being written.
Source=Microsoft.OData.Core
StackTrace:
at Microsoft.OData.Core.ODataFeedAndEntryTypeContext.ValidateAndReturn[T](T value)
at Microsoft.OData.Core.ODataFeedAndEntryTypeContext.get_NavigationSourceName()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.ComputeId()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.ComputeAndCacheId()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.GetId()
at Microsoft.OData.Client.Materialization.MaterializerEntry.UpdateEntityDescriptor()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.ReadEntryCore()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.TryReadEntry(MaterializerEntry& entry)
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.d__0.MoveNext()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.Read()
at Microsoft.OData.Client.Materialization.ODataReaderEntityMaterializer.ReadNextFeedOrEntry()
at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.ReadImplementation()
at Microsoft.OData.Client.MaterializeAtom.MoveNextInternal()
at Microsoft.OData.Client.MaterializeAtom.MoveNext()
at System.Linq.Enumerable.d__94`1.MoveNext()
at System.Collections.Generic -
Trying executing .Execute on the object of type :
Global.Microsoft.OData.Client.DataServiceQuery(Of Customer_Card)
Gives me this object and I can see in fiddler that response is received and correct but accoring to error TotalCount is missing: https://postimg.org/image/eyv1hglnj/ However I got the objext I am supposed to. If I try to call .ToList it first makes call to .Execute and then try to create :
System.Collections.Generic.List(Of NAVEntities.Customer_Card)
But it produces an error and I the object looking like this: https://postimg.org/image/e3ewt9b5j/ Full stacktrace is:
Microsoft.OData.Core.ODataException was unhandled
HResult=-2146233079
Message=When writing a JSON response, a user model must be specified and the entity set and entity type must be passed to the ODataMessageWriter.CreateODataEntryWriter method or the
ODataFeedAndEntrySerializationInfo must be set on the ODataEntry or ODataFeed that is being written.
Source=Microsoft.OData.Core
StackTrace:
at Microsoft.OData.Core.ODataFeedAndEntryTypeContext.ValidateAndReturn[T](T value)
at Microsoft.OData.Core.ODataFeedAndEntryTypeContext.get_NavigationSourceName()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.ComputeId()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.ComputeAndCacheId()
at Microsoft.OData.Core.Evaluation.ODataConventionalEntityMetadataBuilder.GetId()
at Microsoft.OData.Client.Materialization.MaterializerEntry.UpdateEntityDescriptor()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.ReadEntryCore()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.TryReadEntry(MaterializerEntry& entry)
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.d__0.MoveNext()
at Microsoft.OData.Client.Materialization.FeedAndEntryMaterializerAdapter.Read()
at Microsoft.OData.Client.Materialization.ODataReaderEntityMaterializer.ReadNextFeedOrEntry()
at Microsoft.OData.Client.Materialization.ODataEntityMaterializer.ReadImplementation()
at Microsoft.OData.Client.MaterializeAtom.MoveNextInternal()
at Microsoft.OData.Client.MaterializeAtom.MoveNext()
at System.Linq.Enumerable.d__94`1.MoveNext()
at System.Collections.GenericUnfortunately, you're posting "code fragments"; which makes it hard to discern what you are or are not doing. You previously hinted it might be a "relation" thing; yes, data services does "lazy loading"; cannot tell from your post if you addressed this. [How to: Load Related Entities (WCF Data Services)](https://msdn.microsoft.com/en-us/library/dd756366(v=vs.110).aspx)
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Unfortunately, you're posting "code fragments"; which makes it hard to discern what you are or are not doing. You previously hinted it might be a "relation" thing; yes, data services does "lazy loading"; cannot tell from your post if you addressed this. [How to: Load Related Entities (WCF Data Services)](https://msdn.microsoft.com/en-us/library/dd756366(v=vs.110).aspx)
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Lets see if I can put up a sample thing for you. Yes lazyloading might be a thing just like in EF. Need to turn it off maybe? Thanks // zd
-
Lets see if I can put up a sample thing for you. Yes lazyloading might be a thing just like in EF. Need to turn it off maybe? Thanks // zd
Perhaps only using a Browser for now will help to clarify what is going on: [Accessing the Service from a Web Browser (WCF Data Services Quickstart)](https://msdn.microsoft.com/en-us/library/dd728279(v=vs.110).aspx) I suggest you try it.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Cant see anything in fiddler that draws me into that relation-direction. Its just plain-data. Have to dive deeper into that.
I'm thinking the possibility that from Main () can access its copy of Name_Common to do Name_Common.Cls_Common.StCommon = new Name_Common.St_Common(); For now I do not know how to do it because there is an error. So when I want to use a class, I can copy Main's global structure to that of the class. I have remembered that I did a function to make (cast) of one estrcuture to another one. For now I can not make new Name_Common.St_Common(); of Main(). The brain has stopped me for days. I can also someone something about points 2 and 3 of debugger employment? Thank you.
-
I'm thinking the possibility that from Main () can access its copy of Name_Common to do Name_Common.Cls_Common.StCommon = new Name_Common.St_Common(); For now I do not know how to do it because there is an error. So when I want to use a class, I can copy Main's global structure to that of the class. I have remembered that I did a function to make (cast) of one estrcuture to another one. For now I can not make new Name_Common.St_Common(); of Main(). The brain has stopped me for days. I can also someone something about points 2 and 3 of debugger employment? Thank you.
What has this got to do with this question? Please don't hijack others posts.
This space for rent
-
Perhaps only using a Browser for now will help to clarify what is going on: [Accessing the Service from a Web Browser (WCF Data Services Quickstart)](https://msdn.microsoft.com/en-us/library/dd728279(v=vs.110).aspx) I suggest you try it.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Perhaps only using a Browser for now will help to clarify what is going on: [Accessing the Service from a Web Browser (WCF Data Services Quickstart)](https://msdn.microsoft.com/en-us/library/dd728279(v=vs.110).aspx) I suggest you try it.
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
Everything ok with browsing the service. Filtering etc work like a charm. This is for sure client-issue. I have tried to generate proxyclasses using 2 different tools that state they can produce proxy for OData v4. If I try to use Add Service Reference I get en error like this :
Quote:
The document at the url file:///e:/client.xml was not recognized as a known document type. The error message from each known type may help you fix the problem: - Report from 'XML Schema' is 'The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'. - Report from 'DISCO Document' is 'Discovery document at the URL file:///e:/client.xml could not be found.'. - The document format is not recognized. - Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'. - was not expected. If the service is defined in the current solution, try building the solution and adding the service reference again.
Guess That built in proxyclass generator only handles up to V3? This is what my Schema look like:
Thanks
-
Everything ok with browsing the service. Filtering etc work like a charm. This is for sure client-issue. I have tried to generate proxyclasses using 2 different tools that state they can produce proxy for OData v4. If I try to use Add Service Reference I get en error like this :
Quote:
The document at the url file:///e:/client.xml was not recognized as a known document type. The error message from each known type may help you fix the problem: - Report from 'XML Schema' is 'The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'. - Report from 'DISCO Document' is 'Discovery document at the URL file:///e:/client.xml could not be found.'. - The document format is not recognized. - Report from 'WSDL Document' is 'There is an error in XML document (2, 2).'. - was not expected. If the service is defined in the current solution, try building the solution and adding the service reference again.
Guess That built in proxyclass generator only handles up to V3? This is what my Schema look like:
Thanks
Yes; when your previously mentioned you used a "generator" .... It's almost a given you will have less control and less transparency. I usually go "down to the metal" first time around; and then I MAY go "fancy". [OData - the Best Way to REST](http://www.odata.org/) [Home · object/Simple.OData.Client Wiki · GitHub](https://github.com/object/Simple.OData.Client/wiki)
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
Yes; when your previously mentioned you used a "generator" .... It's almost a given you will have less control and less transparency. I usually go "down to the metal" first time around; and then I MAY go "fancy". [OData - the Best Way to REST](http://www.odata.org/) [Home · object/Simple.OData.Client Wiki · GitHub](https://github.com/object/Simple.OData.Client/wiki)
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
Thanks Gerry ... yes I dont like it either but client wanted an easy way to code against Microsoft Dynamics. I have been all over that Odata-site and everything work as intended if you do it the raw way, I do like the look of Simple.OData.Client. Maybe try it out. Have you tested it? We are sending in the question to NAV developement team to see if they have any answer to why it dont work with a generator. Thanks for all your help ;)
-
Thanks Gerry ... yes I dont like it either but client wanted an easy way to code against Microsoft Dynamics. I have been all over that Odata-site and everything work as intended if you do it the raw way, I do like the look of Simple.OData.Client. Maybe try it out. Have you tested it? We are sending in the question to NAV developement team to see if they have any answer to why it dont work with a generator. Thanks for all your help ;)
You're welcome. No, I haven't tried "Simple.OData.Client"; but it has a good "smell". But if your "raw" methods are working, I wouldn't bother. I also wouldn't bother NAV. I would instead consider spending time giving the client an "attitude adjustment".
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal
-
You're welcome. No, I haven't tried "Simple.OData.Client"; but it has a good "smell". But if your "raw" methods are working, I wouldn't bother. I also wouldn't bother NAV. I would instead consider spending time giving the client an "attitude adjustment".
"(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal