SAP Cloud SDK executeHttpRequest请求失败,状态码为407

2020-08-13 11:44发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


大家好,

我正在尝试使用云SDK的" executeHttpRequest"功能向我的内部后端系统创建请求,如下所示:

 const令牌= retrieveJwt(request);
 返回等待executeHttpRequest({destinationName:" MyDestination",jwt:token},request)

不幸的是,这导致407,这意味着我的代理身份验证丢失。 但是,在发送请求之前到达目的地时,我注意到代理身份验证可用。 我通过使用以下功能来做到这一点:

 const destination =等待getDestinationFromDestinationService(" MyDestination",{userJwt:token})
 

知道我缺少什么吗?

在这里您具有从请求到407错误的完整日志:

 2020-08-12T05:25:21.194 + 0000 [APP/PROC/WEB/0] OUT {" message":"正在尝试从目标服务中检索目标。"," level":" info"," custom_fields  ":{" package":" core"," messageContext":" destination-accessor"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.194  Z"," msg":"正在尝试从目标服务中检索目标。"," write_ts":1597209921194," write_at":" 2020-08-12T05:25:21.194Z"}
 2020-08-12T05:25:21.195 + 0000 [APP/PROC/WEB/0] OUT {" message":"无法将特定的XSUAA服务实例与给定的JWT匹配。绑定了以下XSUAA实例:cloud-approuter  !t44784。将选择以下内容:cloud-approuter!t44784。这可能会在系统的其他部分产生错误!"," level":" warn"," custom_fields":{" package":" core",  " messageContext":"环境访问者"},"记录器":" sap-cloud-sdk-logger","时间戳":" 2020-08-12T05:25:21.195Z"," msg":"无法匹配 给定JWT的特定XSUAA服务实例。绑定了以下XSUAA实例:cloud-approuter!t44784。将选择以下实例:cloud-approuter!t44784。这可能会在系统的其他部分产生错误!","  created_ts":1597209921195," write_at":" 2020-08-12T05:25:21.195Z"}
 2020-08-12T05:25:21.438 + 0000 [APP/PROC/WEB/0] OUT {" message":"已成功从目标服务中检索到目标。","级别":" info"," custom_fields":{"  package":" core"," messageContext":" destination-accessor"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.437Z","  msg":"已成功从目标服务中检索到目标。"," write_ts":1597209921437," write_at":" 2020-08-12T05:25:21.437Z"}
 2020-08-12T05:25:21.438 + 0000 [APP/PROC/WEB/0] OUT {" message":"将使用来自连接服务的OnPrem目标代理设置。","级别":" info"," custom_fields  ":{" package":" core"," messageContext":" proxy-util"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.438  Z"," msg":"将使用来自连接服务的OnPrem目标代理设置。"," write_ts":1597209921438," write_at":" 2020-08-12T05:25:21.438Z"}
 2020-08-12T05:25:21.589 + 0000 [APP/PROC/WEB/0] OUT {" message":"将使用来自连接服务的OnPrem目标代理设置。","级别":" info"," custom_fields  ":{" package":" core"," messageContext":" proxy-util"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.588  Z"," msg":"将使用来自连接服务的OnPrem目标代理设置。"," write_ts":1597209921588," write_at":" 2020-08-12T05:25:21.588Z"}
 78XtjpPvNIvZGWQy2ToJhGpdF9fDZe5QDm3mVz_u_fLcFp42a417sGfCyY7UwS2faNL7PqZwH5amOsfzRZYkrLVixUk-TF6N1o6Xzv-4tPDOFD8fzV9Z6ItGzi3EOr5ZXfn_y2QBHNAMJOou6Atrr-7x4Lb3z8d6YI7eKAjAdQgMZgWQ-KjTol6a9f2CEQExwCNZNQ7GFUxIAav4xhDFjUMEQ"}}}
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]出[31m [嵌套] 81-[39m08/12/2020,5:25:21 AM [38; 5; 3m  [ExceptionsHandler] [39m [31mRequest失败,状态码为407 [39m [38; 5; 3m + 661ms [39m
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0] OUT错误:请求失败,状态码为407
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在createError处退出(/home/vcap/deps/0/node_modules/axios/lib/core/createError.js:16:15)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在解决时退出(/home/vcap/deps/0/node_modules/axios/lib/core/settle.js:17:12)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在IncomingMessage.handleStreamEnd(/home/vcap/deps/0/node_modules/axios/lib/adapters/http.js:236:11处退出 )
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在IncomingMessage.emit处退出(events.js:203:15)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在endReadableNT处输出(_stream_visible.js:1145:12)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在process._tickCallback退出(内部/进程/next_tick.js:63:19)
 

我还想知道为什么这会出现在日志"无法将特定的XSUAA服务实例与给定的JWT匹配...."中。当查看解码的令牌并将其与绑定的xsuaa服务进行比较时,它看起来 一样。

提前谢谢!

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


大家好,

我正在尝试使用云SDK的" executeHttpRequest"功能向我的内部后端系统创建请求,如下所示:

 const令牌= retrieveJwt(request);
 返回等待executeHttpRequest({destinationName:" MyDestination",jwt:token},request)

不幸的是,这导致407,这意味着我的代理身份验证丢失。 但是,在发送请求之前到达目的地时,我注意到代理身份验证可用。 我通过使用以下功能来做到这一点:

 const destination =等待getDestinationFromDestinationService(" MyDestination",{userJwt:token})
 

知道我缺少什么吗?

在这里您具有从请求到407错误的完整日志:

 2020-08-12T05:25:21.194 + 0000 [APP/PROC/WEB/0] OUT {" message":"正在尝试从目标服务中检索目标。"," level":" info"," custom_fields  ":{" package":" core"," messageContext":" destination-accessor"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.194  Z"," msg":"正在尝试从目标服务中检索目标。"," write_ts":1597209921194," write_at":" 2020-08-12T05:25:21.194Z"}
 2020-08-12T05:25:21.195 + 0000 [APP/PROC/WEB/0] OUT {" message":"无法将特定的XSUAA服务实例与给定的JWT匹配。绑定了以下XSUAA实例:cloud-approuter  !t44784。将选择以下内容:cloud-approuter!t44784。这可能会在系统的其他部分产生错误!"," level":" warn"," custom_fields":{" package":" core",  " messageContext":"环境访问者"},"记录器":" sap-cloud-sdk-logger","时间戳":" 2020-08-12T05:25:21.195Z"," msg":"无法匹配 给定JWT的特定XSUAA服务实例。绑定了以下XSUAA实例:cloud-approuter!t44784。将选择以下实例:cloud-approuter!t44784。这可能会在系统的其他部分产生错误!","  created_ts":1597209921195," write_at":" 2020-08-12T05:25:21.195Z"}
 2020-08-12T05:25:21.438 + 0000 [APP/PROC/WEB/0] OUT {" message":"已成功从目标服务中检索到目标。","级别":" info"," custom_fields":{"  package":" core"," messageContext":" destination-accessor"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.437Z","  msg":"已成功从目标服务中检索到目标。"," write_ts":1597209921437," write_at":" 2020-08-12T05:25:21.437Z"}
 2020-08-12T05:25:21.438 + 0000 [APP/PROC/WEB/0] OUT {" message":"将使用来自连接服务的OnPrem目标代理设置。","级别":" info"," custom_fields  ":{" package":" core"," messageContext":" proxy-util"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.438  Z"," msg":"将使用来自连接服务的OnPrem目标代理设置。"," write_ts":1597209921438," write_at":" 2020-08-12T05:25:21.438Z"}
 2020-08-12T05:25:21.589 + 0000 [APP/PROC/WEB/0] OUT {" message":"将使用来自连接服务的OnPrem目标代理设置。","级别":" info"," custom_fields  ":{" package":" core"," messageContext":" proxy-util"}," logger":" sap-cloud-sdk-logger"," timestamp":" 2020-08-12T05:25:21.588  Z"," msg":"将使用来自连接服务的OnPrem目标代理设置。"," write_ts":1597209921588," write_at":" 2020-08-12T05:25:21.588Z"}
 78XtjpPvNIvZGWQy2ToJhGpdF9fDZe5QDm3mVz_u_fLcFp42a417sGfCyY7UwS2faNL7PqZwH5amOsfzRZYkrLVixUk-TF6N1o6Xzv-4tPDOFD8fzV9Z6ItGzi3EOr5ZXfn_y2QBHNAMJOou6Atrr-7x4Lb3z8d6YI7eKAjAdQgMZgWQ-KjTol6a9f2CEQExwCNZNQ7GFUxIAav4xhDFjUMEQ"}}}
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]出[31m [嵌套] 81-[39m08/12/2020,5:25:21 AM [38; 5; 3m  [ExceptionsHandler] [39m [31mRequest失败,状态码为407 [39m [38; 5; 3m + 661ms [39m
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0] OUT错误:请求失败,状态码为407
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在createError处退出(/home/vcap/deps/0/node_modules/axios/lib/core/createError.js:16:15)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在解决时退出(/home/vcap/deps/0/node_modules/axios/lib/core/settle.js:17:12)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在IncomingMessage.handleStreamEnd(/home/vcap/deps/0/node_modules/axios/lib/adapters/http.js:236:11处退出 )
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在IncomingMessage.emit处退出(events.js:203:15)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在endReadableNT处输出(_stream_visible.js:1145:12)
 2020-08-12T05:25:21.706 + 0000 [APP/PROC/WEB/0]在process._tickCallback退出(内部/进程/next_tick.js:63:19)
 

我还想知道为什么这会出现在日志"无法将特定的XSUAA服务实例与给定的JWT匹配...."中。当查看解码的令牌并将其与绑定的xsuaa服务进行比较时,它看起来 一样。

提前谢谢!

付费偷看设置
发送
8条回答
学无止境啊~
1楼-- · 2020-08-13 12:07

伍尔特你好早上好

您所做的一切看起来完全正确。 让我们首先调查407问题。 关于XSUAA的奇怪警告并不好,但我想它的重要性不高。

您能尝试一件事吗? 使用getDestinationFromDestinationService获取目标时,您也可以将此对象直接传递给executeHttpRequest(destination)。

如果它有效,那么我已经知道executeHttpRequest方法中的目标查找出了点问题。 但是,相同的代码用于获取executeHttpRequest和getDestinationFromDestinationService内部的目标。

但是有一个区别。 在executeHttpRequest中,使用了一个名为getDestination的方法,该方法通过(1)env变量(2)目标服务实例(3)目标服务进行目标查找。 因此,您也可以尝试从getDestinationFromDestinationService和getDestination获得的结果是否不同。 如果是这样,您很可能在(1)或(2)中定义了一个目的地,然后在名称当然匹配的情况下采用该目的地。

最佳

弗兰克

四川大学会员
2楼-- · 2020-08-13 12:21

感谢弗兰克快速答复。 我也尝试过" getDestinationFromDestinationService",但结果相同...

能不能别闹
3楼-- · 2020-08-13 12:22

如果您对更多详细信息感兴趣,我总是会忘记提及我们新的闪亮的github页面: https://sap.github.io/cloud-sdk/docs/ js/features/connectivity/destination-js-sdk

hongfeng1314
4楼-- · 2020-08-13 12:10

谢谢! 我已经阅读了文档,甚至查看了github上的源代码:)

CPLASF-自律
5楼-- · 2020-08-13 12:01

能否将我从getDestinationFromService接收到的目标对象发送给我,并将任何与安全相关的数据替换为一些虚拟值。

我是小鹏鹏啊
6楼-- · 2020-08-13 12:22

您在这里:

 {originalProperties:
    {名称:'destinationname',
      类型:" HTTP",
      网址:
       'http://virtual-host:virtual-port/sap/opu/odata/sap/ZSERVICE/',
      身份验证:"基本身份验证",
      ProxyType:" OnPremise",
      'HTML5.ConnectionTimeoutInSeconds':'120',
      说明:"我的目的地",
      用户:"用户",
      'HTML5.SocketReadTimeoutInSeconds':'300',
      WebIDEEnabled:" true",
      WebIDESystem:" Systid",
      WebIDE的用法:
       'odata_abap,dev_abap,ui5_execute_abap,bsp_execute_abap,odata_gen',
      密码:" password"},
   authTokens:[],
   证书:[],
   名称:"目的地名称",
   类型:" HTTP",
   网址:
    'http:///virtual-host:virtual-port/sap/opu/odata/sap/ZSERVICE/',
   验证:" BasicAuthentication",
   proxyType:" OnPremise",
   用户名:" user",
   密码:" password",
   isTrustingAllCertificates:否,
   proxyConfiguration:
    {主持人:" connectivityproxy.internal.cf.eu10.hana.ondemand.com",
      端口:" 20003",
      通讯协定:「http」,
      标头:
       {"代理授权":
          '承载者eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vY2ZjcGVhZXh0Y29udHJhY2F1dGhwaWx ...',
         " SAP连通性验证":
          "承载者eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vY2ZjcGVhZXh0Y29udHJhY2F1dGhwaWxvdC5hdXRoZW50aWNhdGlvb ...'}}


 

一周热门 更多>