【问题标题】:Java VDM generator does not work properly for API_SALES_ORDER_SIMULATION_SRV with SAP Cloud SDK version 3.7.0Java VDM 生成器不适用于带有 SAP Cloud SDK 版本 3.7.0 的 API_SALES_ORDER_SIMULATION_SRV
【发布时间】:2020-03-15 15:21:12
【问题描述】:

我正在使用 Java VDM Generator 生成具有 SAP Cloud SDK 原型项目的服务类,版本为 3.7.0。

我使用的 OData 服务是 API_SALES_ORDER_SIMULATION_SRV。我从 SAP API Business Hub 下载了元数据。其实我也在 S/4HANA on-premise 1909 上测试了元数据。问题仍然存在。

我在 pom.xml 中使用的插件如下:

<plugin>
   <groupId>com.sap.cloud.sdk.datamodel</groupId>
   <artifactId>odata-generator-maven-plugin</artifactId>
   <version>3.7.0</version>
   <executions>
       <execution>
           <id>generate-consumption</id>
           <phase>generate-sources</phase>
           <goals>
               <goal>generate</goal>
           </goals>
           <configuration>
               <inputDirectory>${project.basedir}/edmx</inputDirectory>
               <outputDirectory>${project.build.directory}/vdm</outputDirectory>
               <deleteOutputDirectory>true</deleteOutputDirectory>
               <defaultBasePath>/sap/opu/odata/sap/</defaultBasePath>
               <packageName>com.bosch.testvdm</packageName>
               <serviceNameMappingFile>${project.basedir}/serviceNameMappings.properties</serviceNameMappingFile>
               <compileScope>COMPILE</compileScope>
           </configuration>
       </execution>
   </executions>
</plugin>

生成的服务接口/类是 APISALESORDERSIMULATIONSRVService 和 DefaultAPISALESORDERSIMULATIONSRVService。某些方法在服务中丢失。例如。 createSalesOrderSimulationAPI()。

/*
 * Generated by OData VDM code generator of SAP Cloud SDK in version 3.7.0
 */

package com.bosch.testvdm.services;

import javax.annotation.Nonnull;
import com.bosch.testvdm.namespaces.salesordersimulationsrv.batch.APISALESORDERSIMULATIONSRVServiceBatch;
import com.sap.cloud.sdk.datamodel.odata.helper.batch.BatchService;


/**
 * <h3>Details:</h3><table summary='Details'><tr><td align='right'>OData Service:</td><td>API_SALES_ORDER_SIMULATION_SRV</td></tr></table>
 * 
 */
public interface APISALESORDERSIMULATIONSRVService
    extends BatchService<APISALESORDERSIMULATIONSRVServiceBatch>
{

    /**
     * If no other path was provided via the {@link #withServicePath(String)} method, this is the default service path used to access the endpoint.
     * 
     */
    String DEFAULT_SERVICE_PATH = "/sap/opu/odata/sap/API_SALES_ORDER_SIMULATION_SRV";

    /**
     * Overrides the default service path and returns a new service instance with the specified service path. Also adjusts the respective entity URLs.
     * 
     * @param servicePath
     *     Service path that will override the default.
     * @return
     *     A new service instance with the specified service path.
     */
    @Nonnull
    APISALESORDERSIMULATIONSRVService withServicePath(
        @Nonnull
        final String servicePath);
}


    /*
     * Generated by OData VDM code generator of SAP Cloud SDK in version 3.7.0
     */

    package com.bosch.testvdm.services;

    import javax.annotation.Nonnull;
    import javax.inject.Named;
    import com.bosch.testvdm.namespaces.salesordersimulationsrv.batch.DefaultAPISALESORDERSIMULATIONSRVServiceBatch;


    /**
     * <h3>Details:</h3><table summary='Details'><tr><td align='right'>OData Service:</td><td>API_SALES_ORDER_SIMULATION_SRV</td></tr></table>
     * 
     */
    @Named("com.bosch.testvdm.services.DefaultAPISALESORDERSIMULATIONSRVService")
    public class DefaultAPISALESORDERSIMULATIONSRVService
        implements APISALESORDERSIMULATIONSRVService
    {

        @Nonnull
        private final String servicePath;

        /**
         * Creates a service using {@link APISALESORDERSIMULATIONSRVService#DEFAULT_SERVICE_PATH} to send the requests.
         * 
         */
        public DefaultAPISALESORDERSIMULATIONSRVService() {
            servicePath = APISALESORDERSIMULATIONSRVService.DEFAULT_SERVICE_PATH;
        }

        /**
         * Creates a service using the provided service path to send the requests.
         * <p>
         * Used by the fluent {@link #withServicePath(String)} method.
         * 
         */
        private DefaultAPISALESORDERSIMULATIONSRVService(
            @Nonnull
            final String servicePath) {
            this.servicePath = servicePath;
        }

        @Override
        @Nonnull
        public DefaultAPISALESORDERSIMULATIONSRVService withServicePath(
            @Nonnull
            final String servicePath) {
            return new DefaultAPISALESORDERSIMULATIONSRVService(servicePath);
        }

        /**
         * {@inheritDoc}
         * 
         */
        @Override
        @Nonnull
        public DefaultAPISALESORDERSIMULATIONSRVServiceBatch batch() {
            return new DefaultAPISALESORDERSIMULATIONSRVServiceBatch(this);
        }

    }

它适用于 SAP Cloud SDK 3.3.1 版。所有方法都在服务中生成。

顺便说一句,奇怪的是它在 3.7 版的某些 OData 服务上运行良好。

【问题讨论】:

    标签: sap-cloud-sdk


    【解决方案1】:

    更新:SAP Cloud SDK 版本 3.9.0 可用,其中包含针对此问题的修复。


    我查看了这个,发现我们在这些版本之间添加的新功能会导致意外行为。

    为了快速解决问题,您可以尝试删除通常位于 edmx 文件末尾的 &lt;annotation&gt; 块。

    我们正在研究解决此问题,一旦我们有可用的修复程序,我将更新此问题。

    【讨论】:

    • 嗨,Jerry,您介意将 Christoph 的答案标记为“已接受”,以便其他寻找答案的人可以直接看到答案吗?谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-12
    • 2020-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多