5

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"
  } ]
}
dgdev
  • 51
  • 4

2 Answers2

4

You can set the metadata url when you call the serializer. The signature there is: serviceDocument(ServiceMetadata serviceMetadata, String serviceRoot)

In order to call the serializer yourself you need to register your own ServiceDocumentProcessor to override the DefaultProcessor for the service document. You could just copy the code for the service document from the DefaultProcessor and add the serivice root yourself. Here is a link to the DefaultProcessor implementation: https://github.com/apache/olingo-odata4/blob/3786699f018ac2deb1df9571d12bb61ab57f2d8a/lib/server-api/src/main/java/org/apache/olingo/server/api/processor/DefaultProcessor.java

chrisam
  • 553
  • 2
  • 4
2

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();
volandino
  • 21
  • 1