سؤال

I am trying to put together a POC right now for breeze calling an web API Odata service. Can breeze work with the Atom/xml format of the metadatadocument that is being served by default or should it be only in json format.

I checked the source code for web api specifically the ODataMediaTypeFomatters and identified that the ODataPayloadKind of Metadata is not part of the JsonMediaTypeFormatter.

I tried working with the atom/xml format but the breeze client is failing for that call.

Thanks in advance, Teja

هل كانت مفيدة؟

المحلول

We need to distinguish metadata format from data format. AFAIK, OData metadata is always returned as XML. There is not now and never has been a JSON format for metadata. And Breeze has always consumed the XML representation of metadata coming from OData sources (a task outsourced to the dataJS library as I recall).

OData supports a variety of formats for query and save data although increasingly JSON is the only one that seems to matter.

I'm guessing the problem you've experienced is that Web API OData doesn't return the complete metadata that Breeze requires. It's main defect is that it omits definition of the foreign key properties that support associations. Microsoft knows about this and promises to fix it in the future.

Meanwhile, a member of the OData team provided an easy workaround and we've put it in a nuget package to make it even easier.

You'll find this described for our Web API OData sample. That sample is included in the full Breeze download, accessible from the Breeze DownLoad page.

Finally, a question for you. Why did you choose to write your app with Web API OData as opposed to straight Web API? I'm not judging. I'm curious. We want to understand the comparative value points of these closely-related alternatives. Thanks.

نصائح أخرى

Right now breeze only supports json.

However please feel free to add a request for other formats to the Breeze User Voice https://breezejs.uservoice.com/forums/173093-breeze-feature-suggestions. We do take these suggestions seriously.

Also, please take a look at the new Breeze OData sample in the Breeze sample zip.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top