同步场景:如何使用Rest Adapter将响应JSON转换为XML

2020-08-22 09:21发布

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

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


您好,

我正在使用GET方法来获取到Rest Adapter的同步流代理以获取记录。

我能够发出成功的请求,当我在Return中获得响应时,它采用JSON格式,这会导致我的映射失败。

在Rest Receiver适配器中,"数据格式"选项卡,"同步消息的响应格式",如果我选择数据格式为JSON,则错误为

" MP:原因com.ctc.wstx.exc.WstxUnexpectedCharException捕获的异常:序言中的意外字符'{'(代码123);应为'<'

在[row,col {unknown-source}]:[1,1]"

如果选择XML格式,则会以JSON格式获得响应,并按期望的XML结构映射邮件。

示例JSON响应:

{
"数据":[
{
" ID":1,
" OverrideDateDueIndicator":false,
" BusinessUnitCode":" US",
" ReferenceNumber ":" 54",
" JournalID":" QRS",
" TransactionType":" GL",
" AccountNumber":" 1234",
" AccountingMonth":" 2015-07 -01T00:00:00",
" ActivityDate":" 2015-05-01T00:00:00",
" TransactionAmount":-4480.00,
" TransactionVolume":0.00,
" TransactionVolumeUnitOfMeasure":" MCF",
" RevenueGrossAmount":0.00,
" RevenueGrossVolume":0.00,
" SourceDescription":"来自收入的总帐",
" SourceDate":" 2015-10- 02T00:00:00",
" SinglePaymentIndicator":false,
" NonopJIBVoucherIndicator":false,
" OwnerBANumber":" 00123",
" OwnerBASub":1,
" Quantity1Amount ":0.0000000000,
" ArchiveCounter":3,
" ProcessQueueID":33455,
" BatchID":" 1",
" AccountTypeCode":" EX"
},
{
" ID":2,
" OverrideDateDueIndicator":否,
" BusinessUnitCode":" UV",
" ReferenceNumber":" 5455",
" JournalID":" QRS",
" TransactionT ype":" GL",
" AccountNumber":" 1300",
" AccountingMonth":" 2015-07-01T00:00:00",
" ActivityDate":" 2015-05-01T00 :00:00",
" TransactionAmount":480.00,
" TransactionVolume":0.00,
" TransactionVolumeUnitOfMeasure":" MCF",
" RevenueGrossAmount":0.00,
" RevenueGrossVolume" :0.00,
" SourceDescription":"来自收入的总帐",
" SourceDate":" 2015-10-02T00:00:00",
" SinglePaymentIndicator":false,
" NonopJIBVoucherIndicator" :false,
" PropertyNumber":"测试",
" MajorProductCode":" ALL",
" DivisionOrderType":" REV",
" Tier":1,
" Quantity1Amount ":0.0000000000,
" ArchiveCounter":3,
" CostCenter":" test",
" ProcessQueueID":358,
" BatchID":" 1",
" AccountTypeCode" :" IN"
}

],

"消息":[]
}

请告知我的响应源结构如何,以及如何配置Rest Adapter以将JSON转换为XML格式

rest-receiver-adapter-screenshot.jpg response-strucutre.jpg (88.1 kB)

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

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


您好,

我正在使用GET方法来获取到Rest Adapter的同步流代理以获取记录。

我能够发出成功的请求,当我在Return中获得响应时,它采用JSON格式,这会导致我的映射失败。

在Rest Receiver适配器中,"数据格式"选项卡,"同步消息的响应格式",如果我选择数据格式为JSON,则错误为

" MP:原因com.ctc.wstx.exc.WstxUnexpectedCharException捕获的异常:序言中的意外字符'{'(代码123);应为'<'

在[row,col {unknown-source}]:[1,1]"

如果选择XML格式,则会以JSON格式获得响应,并按期望的XML结构映射邮件。

示例JSON响应:

{
"数据":[
{
" ID":1,
" OverrideDateDueIndicator":false,
" BusinessUnitCode":" US",
" ReferenceNumber ":" 54",
" JournalID":" QRS",
" TransactionType":" GL",
" AccountNumber":" 1234",
" AccountingMonth":" 2015-07 -01T00:00:00",
" ActivityDate":" 2015-05-01T00:00:00",
" TransactionAmount":-4480.00,
" TransactionVolume":0.00,
" TransactionVolumeUnitOfMeasure":" MCF",
" RevenueGrossAmount":0.00,
" RevenueGrossVolume":0.00,
" SourceDescription":"来自收入的总帐",
" SourceDate":" 2015-10- 02T00:00:00",
" SinglePaymentIndicator":false,
" NonopJIBVoucherIndicator":false,
" OwnerBANumber":" 00123",
" OwnerBASub":1,
" Quantity1Amount ":0.0000000000,
" ArchiveCounter":3,
" ProcessQueueID":33455,
" BatchID":" 1",
" AccountTypeCode":" EX"
},
{
" ID":2,
" OverrideDateDueIndicator":否,
" BusinessUnitCode":" UV",
" ReferenceNumber":" 5455",
" JournalID":" QRS",
" TransactionT ype":" GL",
" AccountNumber":" 1300",
" AccountingMonth":" 2015-07-01T00:00:00",
" ActivityDate":" 2015-05-01T00 :00:00",
" TransactionAmount":480.00,
" TransactionVolume":0.00,
" TransactionVolumeUnitOfMeasure":" MCF",
" RevenueGrossAmount":0.00,
" RevenueGrossVolume" :0.00,
" SourceDescription":"来自收入的总帐",
" SourceDate":" 2015-10-02T00:00:00",
" SinglePaymentIndicator":false,
" NonopJIBVoucherIndicator" :false,
" PropertyNumber":"测试",
" MajorProductCode":" ALL",
" DivisionOrderType":" REV",
" Tier":1,
" Quantity1Amount ":0.0000000000,
" ArchiveCounter":3,
" CostCenter":" test",
" ProcessQueueID":358,
" BatchID":" 1",
" AccountTypeCode" :" IN"
}

],

"消息":[]
}

请告知我的响应源结构如何,以及如何配置Rest Adapter以将JSON转换为XML格式

rest-receiver-adapter-screenshot.jpg response-strucutre.jpg (88.1 kB)
付费偷看设置
发送
4条回答
葫芦娃快救爷爷
1楼-- · 2020-08-22 09:49

您尝试过这个吗?

渐行渐远_HoldOn
2楼-- · 2020-08-22 09:37

嗨Manoj,

感谢您的回复。 我确实尝试了上述选项。 当我选择JSON作为响应格式时,出现以下错误。 我尝试了不同的组合,但没有运气。

我的PI版本是7.31 SP 19,所以我没有最后选择转换为XML 1.1文档。

Climb_Ma
3楼-- · 2020-08-22 09:56

您好,

能为您解决上述问题吗?

谢谢

Varun

歪着头看世界
4楼-- · 2020-08-22 09:54

嗨,

您能够解决上述问题,我也遇到同样的问题。

一周热门 更多>