In our odata service implementation, the autogenerated metadata can be accessed at:
https://<ourserver>/v1/$metadata
But the BreezeJS tries to access it from https://<ourserver>/v1/Metadata. And it gets a 404 error as the metadata is not served at this location.
How to instruct BreezeJs to find the metadata at any given URL?
The code entityManger.fetchMetadata() is trying reach metadata at https://<ourserver>/v1/Metadata and not at where it is available https://<ourserver>/v1/$metadata
You need to tell Breeze that you are using OData, by default it assumes WebApi. So:
breeze.config.initializeAdapterInstances({ dataService: "OData" });
Also see: http://www.breezejs.com/documentation/odata
Related
I'vve problems with the Olingo Odata v2 Client library. We save the metadata file in our backend and read it from there instead of getting it every time from server because of performance.
But if server changes the structure of data (e.g. adding a new field) the methold call:
ODataFeed feed = EntityProvider.readFeed( contentType,
entityContainer.getEntitySet( entitySetName ), content,
EntityProviderReadProperties.init( ).build( ) );
will run into an Exception:
org.apache.olingo.odata2.api.ep.EntityProviderException: Illegal argument for method call with message 'NewModel2'.
at org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.readNavigationProperty(JsonEntryConsumer.java:279)
at org.apache.olingo.odata2.core.ep.consumer.JsonEntryConsumer.handleName(JsonEntryConsumer.java:178)
where NewModel2 is a new property added later.
Is there any switch to ignore such changes and parse only known properties?
i am trying to connect sapui5/openui5 ODataModel to an odata-server. I want to use a nodejs server with package simple-odata-server. Unfortunately this odata server provides metadata only in xml-format. But sapui5 tries to load metadata in json-format.
Before i switch to another odata server, i want to check, wether sapui5 can load metadata in xml-format. I tried to create the model with several parameters, but ODataModel still tries to load metadata as json.
var oModel = new ODataModel("/odata", {
"metadataUrlParams": "$format=xml",
"json": false
});
Does anybody know, wether i can switch to $format=xml
Thanks in advance,
Torsten
As far as I know the OData protocol metadata is always provided as XML, never seen metadata in JSON format. Also my n-odata-server Qualiture mentioned in the comment above does it. But I never had problems with SAPUI5. It requests the metadata, gets the xml stream and works with it.
Since the metadataUrlParams parameter is of type map I'd suppose it would at least do what you intend like this:
var oModel = new ODataModel("/odata", {
"metadataUrlParams": {
"$format": "xml"
}
});
https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.model.odata.ODataModel.html#constructor
I tried to update one entity in my angularjs client using breezejs library. After calling saveChanges(), it can actually save back in the server and fetched on the client. However, the server did not return the response back. The saveResult.entities is undefined and pop up an error for me. When I took a look at the docs, it mentions 'Some service APIs do not return information about every saved entity. If your server doesn't return such information, you should add the pre-save, cached entity to saveResult.entities yourself'. Could anyone provide an example of how to do this?
This is the code when i am trying to do an update.
manager.saveChanges(entitiesToSave, null, (saveResult) => {
const savedRes = saveResult;
savedRes.entities = entitiesToSave;
return savedRes;
}).then(saveSucceeded);
On the server, you would need to construct the response for an update similar to the way it is for a create:
response.setContent(...); // entities
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
I set up my odata service with Node, MongoDB and JayData. When I hit http://localhost:8000/odata/findash.svc/$metadata in my browser I get the metadata exactly as I would expect.
In the browser console I execute this sample code:
var manager = new breeze.EntityManager('odata/findash.svc');
var query = new breeze.EntityQuery()
.from("accounts");
manager.executeQuery(query).then(function(data){
console.log(data);
}).fail(function(e) {
alert(e);
});
An alert pops up with the message: Error: Metadata query failed for: odata/findash.svc/Metadata; Not Found
The net tab confirms that Breeze is hitting odata/findash.svc/Metadata which produces a 404 instead of odata/findash.svc/$metadata which works fine.
Is there a way to configure this behavior in Breeze or is the problem with my odata setup?
I assume that you meant OData and not JayData in your question. Breeze and JayData are two different products. If not then I'm not sure I understand the question.
I think that you haven't told breeze to use the OData endpoint. By default breeze uses a WebApi endpoint. You can change this via the breeze.config like this:
breeze.config.initializeAdapterInstances({
dataService: "OData", ...
});
Breeze supports both OData and a WebApi endpoints. The OData endpoint ( per the OData spec) returns metadata from '$metadata". The webApi endpoint returns metadata from 'Metadata'.
See: http://www.breezejs.com/documentation/odata
I've been scouring for documentation on the REST adapter that is packaged with ember data, but I can't seem to find any information on how to actually have ember make the json request to the server, or how to retrieve or access the data once it has made the request using this adapter ( the documentation on the ember-data page seems to all be about rolling your own adapter, besides a small paragraph on how to specify if you need to disable bulk commits, though maybe I'm just missing something )
You have to tell your store to use the DS.RESTAdapter and this handles the communication with your server via AJAX calls, see a basic example here
You can get a basic overview how the RESTAdapter is used in the tests.
App = Ember.Application.create({});
App.store = DS.Store.create({
revision: 3,
adapter: DS.RESTAdapter.create({
ajax: function(url, type, hash) {
console.log(arguments);
}
})
});
App.Person = DS.Model.extend({
});
App.Person.createRecord({
});
// tell the store to contact REST service
App.store.commit();