Trying to create custom OData v2 service with data source from S/4HANA Cloud using S/4HANA Cloud SDK

后端 未结 1 363
梦谈多话
梦谈多话 2021-01-28 09:55

I am trying to create a custom OData v2 service in java with an S/4HANA Cloud data source using S/4HANA Cloud SDK. I tried to follow section 8.3 of the SAP Press book \"Extendi

相关标签:
1条回答
  • 2021-01-28 10:21

    The setup for OData V2 provisioning looks a bit different. So remove all modifications you did to use OData V4 provisioning. Then add the following:

    1. Add the following dependencies (instead of the odata-v4 one) to your application/pom.xml file:

      <dependency>
          <groupId>com.sap.cloud.servicesdk.prov</groupId>
          <artifactId>odata2.web</artifactId>
          <exclusions>
              <exclusion>
                  <groupId>javax.servlet</groupId>
                  <artifactId>servlet-api</artifactId>
              </exclusion>
          </exclusions>
      </dependency>
      <dependency>
          <groupId>com.sap.cloud.servicesdk.prov</groupId>
          <artifactId>odata2.xsa</artifactId>
      </dependency>
      <dependency>
          <groupId>com.sap.cloud.servicesdk.prov</groupId>
          <artifactId>odatav2-hybrid</artifactId>
          <exclusions>
              <exclusion>
                  <groupId>javax.servlet</groupId>
                  <artifactId>servlet-api</artifactId>
              </exclusion>
          </exclusions>
      </dependency>
      <dependency>
          <groupId>com.sap.cloud.servicesdk.prov</groupId>
          <artifactId>odatav2-prov</artifactId>
      </dependency>
      
    2. Add the following entries to your application/src/main/webapp/WEB-INF/web.xml file, replacing YOUR.PACKAGE with a package to search for your OData endpoints:

      <servlet>
          <servlet-name>ODataServlet</servlet-name>
          <servlet-class>org.apache.olingo.odata2.core.servlet.ODataServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
          <init-param>
              <param-name>org.apache.olingo.odata2.service.factory</param-name>
              <param-value>
                  com.sap.cloud.sdk.service.prov.v2.rt.core.CloudSDKODataServiceFactory
              </param-value>
          </init-param>
          <init-param>
              <param-name>org.apache.olingo.odata2.path.split</param-name>
              <param-value>1</param-value>
          </init-param>
      </servlet>
      <servlet-mapping>
          <servlet-name>ODataServlet</servlet-name>
          <url-pattern>/odata/v2/*</url-pattern>
      </servlet-mapping>
      <context-param>
          <param-name>package</param-name>
          <param-value>YOUR.PACKAGE</param-value>
      </context-param>
      <listener>
          <listener-class>
              com.sap.cloud.sdk.service.prov.v2.rt.core.web.ServletListener
          </listener-class>
      </listener>
      
    3. Add an OData V2 edmx file to the application/src/main/resources/edmx directory.

    These steps should get your OData V2 Provisioning service up and running.

    0 讨论(0)
提交回复
热议问题