0

我使用的 OData 服务是 SAP API Business Hub 中的 API_SALES_ORDER_SRV。

创建销售订单的有效载荷如下。它在 SAP 网关客户端中运行良好。

{
  "DistributionChannel": "01",
  "OrganizationDivision": "01",
  "SalesOrderType": "***",
  "SalesOrganization": "***",
  "SoldToParty": "***",
  "to_Item": [
  {
    "SalesOrderItem" : "10",
    "RequestedQuantity": "10",
    "Material": "***"
  }
  ]
}

但是当我使用 Cloud SDK 创建销售订单时,我收到以下错误消息。

2019-11-12 19:51:02.870 ERROR 10392 --- [nio-8080-exec-8] c.b.h.service.MySalesOrderService        : The endpoint responded with HTTP error code 500.

Full error message: 
Error when processing resource

com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler$ErpODataException: The endpoint responded with HTTP error code 500.

Full error message: 
Error when processing resource
    at com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler.createException(ODataVdmErrorResultHandler.java:114)
    at com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler.createError(ODataVdmErrorResultHandler.java:94)
    at com.sap.cloud.sdk.datamodel.odata.helper.ODataVdmErrorResultHandler.createError(ODataVdmErrorResultHandler.java:31)
    at com.sap.cloud.sdk.odatav2.connectivity.internal.ODataConnectivityUtil.checkHttpStatus(ODataConnectivityUtil.java:217)
    at com.sap.cloud.sdk.odatav2.connectivity.impl.ODataCreateRequestImpl.create(ODataCreateRequestImpl.java:275)
    at com.sap.cloud.sdk.odatav2.connectivity.impl.ODataCreateRequestImpl.handleExecute(ODataCreateRequestImpl.java:391)
    at com.sap.cloud.sdk.odatav2.connectivity.impl.ODataCreateRequestImpl.execute(ODataCreateRequestImpl.java:367)
    at com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperCreate.execute(FluentHelperCreate.java:155)
    at com.bosch.hackathon.service.MySalesOrderService.createSalesOrder(MySalesOrderService.java:451)
    at com.bosch.hackathon.controllers.MySalesOrderController.createSalesOrderSDK(MySalesOrderController.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:215)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:142)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:998)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:901)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:875)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.lambda$doFilter$1(RequestAccessorFilter.java:71)
    at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.lambda$execute$0(AbstractThreadContextExecutor.java:317)
    at com.sap.cloud.sdk.cloudplatform.thread.ThreadContextCallable.call(ThreadContextCallable.java:247)
    at com.sap.cloud.sdk.cloudplatform.thread.AbstractThreadContextExecutor.execute(AbstractThreadContextExecutor.java:319)
    at com.sap.cloud.sdk.cloudplatform.servlet.RequestAccessorFilter.doFilter(RequestAccessorFilter.java:71)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

2019-11-12 19:51:02.888  WARN 10392 --- [nio-8080-exec-8] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [com.bosch.hackathon.exception.BusinessException: The endpoint responded with HTTP error code 500.

Full error message: 
Error when processing resource]

我用来创建销售订单的代码如下。首先,我构建了一个销售订单对象,然后将其用作方法 createSalesOrder 的参数。

private SalesOrder buildSalesOrderObject() {
    SalesOrderItem item = SalesOrderItem.builder()
                                         .salesOrderItem("myplant")
                                         .material("mymaterial")
                                         .requestedQuantity(new BigDecimal(10))
                                         .build();

    SalesOrder salesOrder = SalesOrder.builder()
                                       .salesOrderType("YTA")
                                       .salesOrganization("myso")
                                       .distributionChannel("01")
                                       .organizationDivision("01")
                                       .soldToParty("party")
                                       .item(item)
                                       .build();

    return salesOrder;
}

public SalesOrder createSalesOrder() throws BusinessException {

    SalesOrder salesOrderCreated = buildSalesOrderObject();
    try {
        salesOrderCreated = salesOrderService.createSalesOrder(salesOrder)
                                             .execute(DestinationUtil.getHttpDestinationT4X());
    } catch (ODataException e) {
        log.error(e.getMessage(), e);
        throw BusinessException.convert(e);
    }

    return salesOrderCreated;
}

你能看看这个问题吗?

SAP Cloud SDK 版本:3.3.1

S/4HANA 本地版本:1909

提供电报日志。

2019-11-15 08:59:14.717 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {}->http://host:8091][total kept alive: 0; route allocated: 0 of 100; total allocated: 0 of 200]
2019-11-15 08:59:14.731 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 0][route: {}->http://host:8091][total kept alive: 0; route allocated: 1 of 100; total allocated: 1 of 200]
2019-11-15 08:59:14.733 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Opening connection {}->http://host:8091
2019-11-15 08:59:14.944 DEBUG 15276 --- [nio-8080-exec-5] .i.c.DefaultHttpClientConnectionOperator : Connecting to host/ip1:8091
2019-11-15 08:59:15.161 DEBUG 15276 --- [nio-8080-exec-5] .i.c.DefaultHttpClientConnectionOperator : Connection established ip2:58702<->ip1:8091
2019-11-15 08:59:15.162 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Executing request GET /sap/opu/odata/sap/API_SALES_ORDER_SRV/$metadata HTTP/1.1
2019-11-15 08:59:15.162 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Proxy auth state: UNCHALLENGED
2019-11-15 08:59:15.163 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> GET /sap/opu/odata/sap/API_SALES_ORDER_SRV/$metadata HTTP/1.1
2019-11-15 08:59:15.163 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientWrapper$ApacheHttpHeader@65d86a53
2019-11-15 08:59:15.163 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Host: host:8091
2019-11-15 08:59:15.163 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Connection: Keep-Alive
2019-11-15 08:59:15.163 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.10 (Java/1.8.0_191)
2019-11-15 08:59:15.164 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Accept-Encoding: gzip,deflate
2019-11-15 08:59:16.485 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << HTTP/1.1 200 OK
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << set-cookie: sap-usercontext=sap-client=011; path=/
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << set-cookie: MYSAPSSO2=***; path=/; domain=***
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << set-cookie: SAP_SESSIONID_***_011=***; path=/
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << content-type: application/xml
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << content-length: 8058
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << last-modified: Mon, 21 Oct 2019 07:48:47 GMT
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << cache-control: max-age=0
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << dataserviceversion: 2.0
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-processing-info: ODataBEP=,crp=,RAL=,st=,MedCacheHub=Table,codeployed=X,softstate=
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-server: true
2019-11-15 08:59:16.486 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-perf-fesrec: 893169.000000
2019-11-15 08:59:16.487 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << content-encoding: gzip
2019-11-15 08:59:16.492 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Connection can be kept alive indefinitely
2019-11-15 08:59:16.496 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.c.protocol.ResponseProcessCookies  : Cookie accepted [sap-usercontext="sap-client=011", version:0, domain:host, path:/, expiry:null]
2019-11-15 08:59:16.497 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.c.protocol.ResponseProcessCookies  : Cookie accepted [MYSAPSSO2="***", version:0, domain:***, path:/, expiry:null]
2019-11-15 08:59:16.497 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.c.protocol.ResponseProcessCookies  : Cookie accepted [SAP_SESSIONID_***_011="***", version:0, domain:host, path:/, expiry:null]
2019-11-15 08:59:16.621 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection [id: 0][route: {}->http://host:8091] can be kept alive indefinitely
2019-11-15 08:59:16.622 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: set socket timeout to 0
2019-11-15 08:59:16.622 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 0][route: {}->http://host:8091][total kept alive: 1; route allocated: 1 of 100; total allocated: 1 of 200]
2019-11-15 08:59:16.624 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : CookieSpec selected: default
2019-11-15 08:59:16.641 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: MYSAPSSO2][value: ***][domain: ***][path: /][expiry: null] match [host:8091/sap/opu/odata/sap/API_SALES_ORDER_SRV]
2019-11-15 08:59:16.642 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: SAP_SESSIONID_***_011][value: ***][domain: host][path: /][expiry: null] match [host:8091/sap/opu/odata/sap/API_SALES_ORDER_SRV]
2019-11-15 08:59:16.642 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: sap-usercontext][value: sap-client=011][domain: host][path: /][expiry: null] match [host:8091/sap/opu/odata/sap/API_SALES_ORDER_SRV]
2019-11-15 08:59:16.642 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAuthCache   : Auth cache not set in the context
2019-11-15 08:59:16.642 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {}->http://host:8091][total kept alive: 1; route allocated: 1 of 100; total allocated: 1 of 200]
2019-11-15 08:59:16.642 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 0][route: {}->http://host:8091][total kept alive: 0; route allocated: 1 of 100; total allocated: 1 of 200]
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: set socket timeout to 0
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Executing request HEAD /sap/opu/odata/sap/API_SALES_ORDER_SRV HTTP/1.1
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Proxy auth state: UNCHALLENGED
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> HEAD /sap/opu/odata/sap/API_SALES_ORDER_SRV HTTP/1.1
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> x-csrf-token: Fetch
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientWrapper$ApacheHttpHeader@54937cbe
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Host: host:8091
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Connection: Keep-Alive
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.10 (Java/1.8.0_191)
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Cookie: MYSAPSSO2=***; SAP_SESSIONID_***_011=***; sap-usercontext=sap-client=011
2019-11-15 08:59:16.643 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Accept-Encoding: gzip,deflate
2019-11-15 08:59:16.902 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << HTTP/1.1 200 OK
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << content-type: text/html
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << content-length: 0
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << x-csrf-token: jgGDK5ILPjPZmMUDQJmvLg==
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << dataserviceversion: 2.0
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << cache-control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << pragma: no-cache
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << expires: Tue, 03 Jul 2001 06:00:00 GMT
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-processing-info: ODataBEP=,crp=,RAL=,st=,MedCacheHub=,codeployed=,softstate=
2019-11-15 08:59:16.903 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-server: true
2019-11-15 08:59:16.904 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-perf-fesrec: 49848.000000
2019-11-15 08:59:16.904 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Connection can be kept alive indefinitely
2019-11-15 08:59:16.904 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection [id: 0][route: {}->http://host:8091] can be kept alive indefinitely
2019-11-15 08:59:16.904 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: set socket timeout to 0
2019-11-15 08:59:16.904 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 0][route: {}->http://host:8091][total kept alive: 1; route allocated: 1 of 100; total allocated: 1 of 200]
2019-11-15 08:59:16.924 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : CookieSpec selected: default
2019-11-15 08:59:16.924 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: MYSAPSSO2][value:***][domain: ***][path: /][expiry: null] match [host:8091/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder]
2019-11-15 08:59:16.924 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: SAP_SESSIONID_***_011][value: ***][domain: host][path: /][expiry: null] match [host:8091/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder]
2019-11-15 08:59:16.925 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAddCookies  : Cookie [version: 0][name: sap-usercontext][value: sap-client=011][domain: host][path: /][expiry: null] match [host:8091/sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder]
2019-11-15 08:59:16.925 DEBUG 15276 --- [nio-8080-exec-5] o.a.h.client.protocol.RequestAuthCache   : Auth cache not set in the context
2019-11-15 08:59:16.925 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {}->http://host:8091][total kept alive: 1; route allocated: 1 of 100; total allocated: 1 of 200]
2019-11-15 08:59:16.925 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 0][route: {}->http://host:8091][total kept alive: 0; route allocated: 1 of 100; total allocated: 1 of 200]
2019-11-15 08:59:16.925 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: set socket timeout to 0
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Executing request POST /sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder HTTP/1.1
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Proxy auth state: UNCHALLENGED
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> POST /sap/opu/odata/sap/API_SALES_ORDER_SRV/A_SalesOrder HTTP/1.1
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> x-csrf-token: jgGDK5ILPjPZmMUDQJmvLg==
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Content-Type: application/json
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Accept: application/json
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientWrapper$ApacheHttpHeader@f38e7be
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Content-Length: 218
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Host: host:8091
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Connection: Keep-Alive
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.10 (Java/1.8.0_191)
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Cookie: MYSAPSSO2=***; SAP_SESSIONID_***_011=***; sap-usercontext=sap-client=011
2019-11-15 08:59:16.926 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 >> Accept-Encoding: gzip,deflate
2019-11-15 08:59:17.150 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << HTTP/1.1 500 Internal Server Error
2019-11-15 08:59:17.150 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << content-type: text/plain; charset=utf-8
2019-11-15 08:59:17.150 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << content-length: 30
2019-11-15 08:59:17.150 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-processing-info: ODataBEP=,crp=,RAL=,st=,MedCacheHub=,codeployed=X,softstate=
2019-11-15 08:59:17.151 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-server: true
2019-11-15 08:59:17.151 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << sap-perf-fesrec: 13762.000000
2019-11-15 08:59:17.151 DEBUG 15276 --- [nio-8080-exec-5] org.apache.http.headers                  : http-outgoing-0 << connection: close
2019-11-15 08:59:17.157 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: Close connection
2019-11-15 08:59:17.158 DEBUG 15276 --- [nio-8080-exec-5] o.a.http.impl.execchain.MainClientExec   : Connection discarded
2019-11-15 08:59:17.158 DEBUG 15276 --- [nio-8080-exec-5] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 0][route: {}->http://host:8091][total kept alive: 0; route allocated: 0 of 100; total allocated: 0 of 200]
2019-11-15 08:59:17.161 ERROR 15276 --- [nio-8080-exec-5] c.b.h.service.MySalesOrderService        : The endpoint responded with HTTP error code 500.

DestinationUtil 类

public class DestinationUtil {

//  @Value("${destination.http.t4x}")
//  private String destinationName;

    public static HttpDestination getHttpDestinationT4X() {
        Destination destination = DestinationAccessor.getDestination("***");
        return destination.asHttp();
    }

    public static HttpDestination getHttpDestinationS4X() {
        Destination destination = DestinationAccessor.getDestination("***");
        return destination.asHttp();
    }

}
4

1 回答 1

2

最后我找到了根本原因。这是由于 S4HANA 系统上销售订单服务的 ICF 节点配置。默认情况下,GUI配置的参数是~CHECK_CSRF_TOKEN 0。也就是说,xsrf检查被禁用并切换到X-Requested-With。我需要在 HTTP 请求标头中提供参数 X-Requested-With。

于 2020-01-02T06:52:39.890 回答