在Spring RestController中使用com.sap.cloud.sdk.s4hana.connectivity.rfc.BapiQuery

时间:2018-05-15 08:35:57

标签: java s4sdk

我试图从Spring REST控制器调用BAPI。 对后端系统的调用工作正常,但是返回ResponseEntity导致错误getOutputStream()已经为此响应调用”

@RequestMapping( method = RequestMethod.GET ) 
public ResponseEntity<List<ExportingCostCenterInformation>> getBusinessPartners()
{
    final ErpEndpoint endpoint = new ErpEndpoint(new ErpConfigContext("ErpQueryEndpoint_RFC"));

    final BapiQuery query = new BapiQuery("BAPI_COSTCENTER_GETLIST")
        .withExporting("CONTROLLINGAREA", "KOKRS", "1000");

    List<ExportingCostCenterInformation> ecci = null;
    try {
        ecci = query.execute(endpoint)
            .get("COSTCENTER_LIST")
            .getAsCollection()
            .asList(ExportingCostCenterInformation.class);
    } catch (UnsupportedOperationException | IllegalArgumentException | QuerySerializationException | DestinationNotFoundException | DestinationAccessException | QueryExecutionException e) {
        // ...
    } 

    return ResponseEntity.ok(ecci);         
}

出现此错误的任何想法?

1 个答案:

答案 0 :(得分:1)

吸气鬼&amp;类ExportingCostCenterInformation的setter方法没有很好地定义。那就是问题。