SAP PO中的GateWay查找

2020-08-20 22:17发布

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

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


您好,

我有一个类似Mail to Gateway hub的方案。 ODATA服务器作为Web服务使用。 我将邮件配置为REST方案。

我将收到一封邮件,PO将读取该邮件以及转换为json格式并尝试发送到网关系统的邮件正文内容。

在过程的中间,PO必须从odata serverice中选择CRSF令牌值并发布数据。我创建了UDF来读取通道并获取令牌值。

字符串令牌="";
StringBuffer sb = new StringBuffer();

//1.获取通道的系统访问器。
String party =""; //不能将空值从Directory传递到映射参数。
Channel RESTchannel = LookupService.getChannel(service,channel);
SystemAccessor访问器= LookupService.getSystemAccessor(RESTchannel);
container.getTrace()。addInfo("令牌查找的参数-服务:" + service +",频道:" +频道);
try {
//2.根据数据类型创建有效负载。
//将service.getBinaryPayload()用于二进制有效负载,
//或将service.getTextPayload()用于文本有效负载 。
InputStream inputStream;
字符串reqString =" grant_type = client_credentials&client_id =" + username +"&client_secret =" + password;
container.getTrace()。addDebugMessage(" Request:" + reqString);
inputStream =(InputStream)新的ByteArrayInputStream(reqString.getBytes());
com.sap.aii.mapping.lookup.Payload有效负载= LookupService.getXmlPayload(inputStream);
//3.执行查找。
com.sap.aii.mapping.lookup.Payload result = accessor.call(payload);
//4.解析结果,用真实的方法可以更好地实现 JSON解析器
byte [] b =新的byte [4096];
for(int n;(n = result.getContent()。read(b))!= -1;){
sb。 append(new String(b,0,n));
}
container.getTrace()。addDebugMessage(" Response:" + sb);
int i = sb.indexOf(" \" x -csrf-token \":\"")+ 0;
//int j = sb.indexOf(" \" token_type \"");
令牌= sb.substring(i,24); < br> container.getTrace()。addInfo(" Token:" + token);

}
catch(异常e){
e.printStackTrace();
}
最终{

//5.关闭访问器以释放资源。
if(accessor!= null)accessor.close();
}
返回令牌;

我试图将频道名称和服务名称以及用户名和密码作为参数传递。 当我尝试执行映射时,出现"找不到通道异常"之类的错误

请帮助我解决问题。

我可以获取令牌值并成功通过邮递员发布数据。

致谢

Swathi

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

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


您好,

我有一个类似Mail to Gateway hub的方案。 ODATA服务器作为Web服务使用。 我将邮件配置为REST方案。

我将收到一封邮件,PO将读取该邮件以及转换为json格式并尝试发送到网关系统的邮件正文内容。

在过程的中间,PO必须从odata serverice中选择CRSF令牌值并发布数据。我创建了UDF来读取通道并获取令牌值。

字符串令牌="";
StringBuffer sb = new StringBuffer();

//1.获取通道的系统访问器。
String party =""; //不能将空值从Directory传递到映射参数。
Channel RESTchannel = LookupService.getChannel(service,channel);
SystemAccessor访问器= LookupService.getSystemAccessor(RESTchannel);
container.getTrace()。addInfo("令牌查找的参数-服务:" + service +",频道:" +频道);
try {
//2.根据数据类型创建有效负载。
//将service.getBinaryPayload()用于二进制有效负载,
//或将service.getTextPayload()用于文本有效负载 。
InputStream inputStream;
字符串reqString =" grant_type = client_credentials&client_id =" + username +"&client_secret =" + password;
container.getTrace()。addDebugMessage(" Request:" + reqString);
inputStream =(InputStream)新的ByteArrayInputStream(reqString.getBytes());
com.sap.aii.mapping.lookup.Payload有效负载= LookupService.getXmlPayload(inputStream);
//3.执行查找。
com.sap.aii.mapping.lookup.Payload result = accessor.call(payload);
//4.解析结果,用真实的方法可以更好地实现 JSON解析器
byte [] b =新的byte [4096];
for(int n;(n = result.getContent()。read(b))!= -1;){
sb。 append(new String(b,0,n));
}
container.getTrace()。addDebugMessage(" Response:" + sb);
int i = sb.indexOf(" \" x -csrf-token \":\"")+ 0;
//int j = sb.indexOf(" \" token_type \"");
令牌= sb.substring(i,24); < br> container.getTrace()。addInfo(" Token:" + token);

}
catch(异常e){
e.printStackTrace();
}
最终{

//5.关闭访问器以释放资源。
if(accessor!= null)accessor.close();
}
返回令牌;

我试图将频道名称和服务名称以及用户名和密码作为参数传递。 当我尝试执行映射时,出现"找不到通道异常"之类的错误

请帮助我解决问题。

我可以获取令牌值并成功通过邮递员发布数据。

致谢

Swathi

付费偷看设置
发送
1条回答
打个大熊猫
1楼-- · 2020-08-20 22:40

HI spalasan p,

请实施下一个解决方案(逐步):

https://blogs.sap.com/2018/05/29/handling-x-csrf-token-with-sap-pipo/

致谢

一周热门 更多>