How do I include a full metadata URI in Olingo OData Service Document?

Viewed 1267

I created a sample OData service by following the steps outlined at the Apache Lingo tutorial.

The default Service Document received by the client is:

{
  "@odata.context" : "$metadata",
  "value" : [
  {
    "name" : "Products",
    "url" : "Products"
  } ]
}

Is there a way to configure Olingo to include the full metadata uri in the document? Specifically, assuming the service is running at http://localhost:8080/DemoService/DemoService.svc/, I'd like the Service Document to be the following:

{
  "@odata.context" : "http://localhost:8080/DemoService/DemoService.svc$metadata",
  "value" : [
  {
    "name" : "Products",
    "url" : "Products"
  } ]
}
2 Answers

Set service root URI to the "serviceRoot" property of ContextURL in EntityCollectionProcessor and EntityProcessor.

ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).serviceRoot(<service root URI>).build();
Related