RestRequest - 特殊字符 - JSON 发生解析错误
RestRequest - Special characters - JSON parsing errors have occurred
我有简单的 RESTRequest 节点。作为回应,我从 SOAP-UI 模型发送 JSON。
JSON 看起来像这样:
{
"SnapshotVersion": "43f4acca-b11a-4afe-b9bb-30af9864c3a0",
"TotalExtraPrice": 0,
"TotalPrice": 0,
"Příliš žluťoučký Kůň": "úpěl dábelské ódy"
}
如果我只发送前 3 个元素,JSON 解析器不会抛出解析器异常,但是当添加 "Příliš žluťoučký Kůň": "úpěl dábelské ódy"
元素时,解析器会抛出此消息:
JSON
Data
SnapshotVersion:CHARACTER:43f4acca-b11a-4afe-b9bb-30af9864c3a0
TotalExtraPrice:INTEGER:0
TotalPrice:INTEGER:0
CHARACTER:Unconvertable character
CHARACTER:JSON parsing errors have occurred
我试过 this 修复,但它不起作用:
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/json; charset=utf-8';
我什至试过发送 SOAP-UI header Content-Type: application/json; charset=utf-8
我的 properties 和 HTTPResquestHeader 看起来像这样:
Properties
MessageSet:CHARACTER:
MessageType:CHARACTER:
MessageFormat:CHARACTER:
Encoding:INTEGER:546
CodedCharSetId:INTEGER:1208
Transactional:BOOLEAN:true
Persistence:BOOLEAN:false
CreationTime:TIMESTAMP:java.util.GregorianCalendar[time=1551971569190,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Prague",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=141,lastRule=java.util.SimpleTimeZone[id=Europe/Prague,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=2019,MONTH=2,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=7,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=12,SECOND=49,MILLISECOND=190,ZONE_OFFSET=?,DST_OFFSET=?]
ExpirationTime:INTEGER:-1
Priority:INTEGER:0
ReplyIdentifier:BLOB:[B@3613bded
ReplyProtocol:CHARACTER:MQ
Topic:UNKNOWN:null
ContentType:CHARACTER:application/json; charset=utf-8
IdentitySourceType:CHARACTER:
IdentitySourceToken:CHARACTER:
IdentitySourcePassword:CHARACTER:
IdentitySourceIssuedBy:CHARACTER:
IdentityMappedType:CHARACTER:
IdentityMappedToken:CHARACTER:
IdentityMappedPassword:CHARACTER:
IdentityMappedIssuedBy:CHARACTER:
HTTPRequestHeader
Content-Type:CHARACTER:application/json; charset=utf-8
我想这肯定还是有encoding或者ccsid的东西吧
编辑 1:
IIB版本:10.0.0.13
完整错误信息:
ExceptionList
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\DataFlowEngine\MessageServices\ImbDataFlowNode.cpp
Line:INTEGER:1251
Function:CHARACTER:ImbDataFlowNode::createExceptionList
Type:CHARACTER:ComIbmMQInputNode
Name:CHARACTER:API18099_O_CCGetV2#FCMComposite_1_6.vwg/skoda/eai/generic/in/mq/GEN90040_Generic_In_MQ#FCMComposite_1_1
Label:CHARACTER:API18099_O_CCGetV2.GEN90040_Generic_In_MQ.MQ Input
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Node throwing exception
Insert
Type:INTEGER:14
Text:CHARACTER:API18099_O_CCGetV2.GEN90040_Generic_In_MQ.MQ Input
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\DataFlowEngine\SQLNodeLibrary\ImbComputeNode.cpp
Line:INTEGER:515
Function:CHARACTER:ImbComputeNode::evaluate
Type:CHARACTER:ComIbmComputeNode
Name:CHARACTER:API18099_O_CCGetV2#FCMComposite_1_5
Label:CHARACTER:API18099_O_CCGetV2.MapAndRouteBack
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Caught exception and rethrowing
Insert
Type:INTEGER:14
Text:CHARACTER:API18099_O_CCGetV2.MapAndRouteBack
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\DataFlowEngine\ImbRdl\ImbRdlStatementGroup.cpp
Line:INTEGER:792
Function:CHARACTER:SqlStatementGroup::execute
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2488
Text:CHARACTER:Error detected, rethrowing
Insert
Type:INTEGER:5
Text:CHARACTER:.API18099_O_CCGetV2_MapAndRouteBack.Main
Insert
Type:INTEGER:5
Text:CHARACTER:43.4
Insert
Type:INTEGER:5
Text:CHARACTER:SET refOutBody = InputRoot.JSON.Data;
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\CommonServices\ImbConverter.cpp
Line:INTEGER:628
Function:CHARACTER:ImbConverterCPP::internalToUnicode
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2135
Text:CHARACTER:Unconvertable character
Insert
Type:INTEGER:5
Text:CHARACTER:f8
Insert
Type:INTEGER:5
Text:CHARACTER:50f8ed6c699a209e6c759df375e86bfd204bf9f2
Insert
Type:INTEGER:2
Text:CHARACTER:1208
在我使用错误解析的 json 消息进行映射后抛出错误消息。
Soap-UI 这里有点棘手。
我的错误是在响应 Header 中发送了 Content-Type(正如 here 所回答的那样),但在那之后 Soap-UI 响应仍然采用与 UTF 不同的编码-8,即使 header 设置正确。
对于 UTF-8,您必须设置参数 JAVA_OPTS=-Dfile.encoding=UTF8
- in
<Soap-UI home>\bin\soapui.bat
(对于 .zip 版本)
- 或
<Soap-UI home>\bin\SoapUI-5.4.0.vmoptions
(对于 .exe 版本)
我有简单的 RESTRequest 节点。作为回应,我从 SOAP-UI 模型发送 JSON。 JSON 看起来像这样:
{
"SnapshotVersion": "43f4acca-b11a-4afe-b9bb-30af9864c3a0",
"TotalExtraPrice": 0,
"TotalPrice": 0,
"Příliš žluťoučký Kůň": "úpěl dábelské ódy"
}
如果我只发送前 3 个元素,JSON 解析器不会抛出解析器异常,但是当添加 "Příliš žluťoučký Kůň": "úpěl dábelské ódy"
元素时,解析器会抛出此消息:
JSON
Data
SnapshotVersion:CHARACTER:43f4acca-b11a-4afe-b9bb-30af9864c3a0
TotalExtraPrice:INTEGER:0
TotalPrice:INTEGER:0
CHARACTER:Unconvertable character
CHARACTER:JSON parsing errors have occurred
我试过 this 修复,但它不起作用:
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/json; charset=utf-8';
我什至试过发送 SOAP-UI header Content-Type: application/json; charset=utf-8
我的 properties 和 HTTPResquestHeader 看起来像这样:
Properties
MessageSet:CHARACTER:
MessageType:CHARACTER:
MessageFormat:CHARACTER:
Encoding:INTEGER:546
CodedCharSetId:INTEGER:1208
Transactional:BOOLEAN:true
Persistence:BOOLEAN:false
CreationTime:TIMESTAMP:java.util.GregorianCalendar[time=1551971569190,areFieldsSet=true,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Prague",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=141,lastRule=java.util.SimpleTimeZone[id=Europe/Prague,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=2019,MONTH=2,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=7,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=12,SECOND=49,MILLISECOND=190,ZONE_OFFSET=?,DST_OFFSET=?]
ExpirationTime:INTEGER:-1
Priority:INTEGER:0
ReplyIdentifier:BLOB:[B@3613bded
ReplyProtocol:CHARACTER:MQ
Topic:UNKNOWN:null
ContentType:CHARACTER:application/json; charset=utf-8
IdentitySourceType:CHARACTER:
IdentitySourceToken:CHARACTER:
IdentitySourcePassword:CHARACTER:
IdentitySourceIssuedBy:CHARACTER:
IdentityMappedType:CHARACTER:
IdentityMappedToken:CHARACTER:
IdentityMappedPassword:CHARACTER:
IdentityMappedIssuedBy:CHARACTER:
HTTPRequestHeader
Content-Type:CHARACTER:application/json; charset=utf-8
我想这肯定还是有encoding或者ccsid的东西吧
编辑 1:
IIB版本:10.0.0.13
完整错误信息:
ExceptionList
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\DataFlowEngine\MessageServices\ImbDataFlowNode.cpp
Line:INTEGER:1251
Function:CHARACTER:ImbDataFlowNode::createExceptionList
Type:CHARACTER:ComIbmMQInputNode
Name:CHARACTER:API18099_O_CCGetV2#FCMComposite_1_6.vwg/skoda/eai/generic/in/mq/GEN90040_Generic_In_MQ#FCMComposite_1_1
Label:CHARACTER:API18099_O_CCGetV2.GEN90040_Generic_In_MQ.MQ Input
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Node throwing exception
Insert
Type:INTEGER:14
Text:CHARACTER:API18099_O_CCGetV2.GEN90040_Generic_In_MQ.MQ Input
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\DataFlowEngine\SQLNodeLibrary\ImbComputeNode.cpp
Line:INTEGER:515
Function:CHARACTER:ImbComputeNode::evaluate
Type:CHARACTER:ComIbmComputeNode
Name:CHARACTER:API18099_O_CCGetV2#FCMComposite_1_5
Label:CHARACTER:API18099_O_CCGetV2.MapAndRouteBack
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2230
Text:CHARACTER:Caught exception and rethrowing
Insert
Type:INTEGER:14
Text:CHARACTER:API18099_O_CCGetV2.MapAndRouteBack
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\DataFlowEngine\ImbRdl\ImbRdlStatementGroup.cpp
Line:INTEGER:792
Function:CHARACTER:SqlStatementGroup::execute
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2488
Text:CHARACTER:Error detected, rethrowing
Insert
Type:INTEGER:5
Text:CHARACTER:.API18099_O_CCGetV2_MapAndRouteBack.Main
Insert
Type:INTEGER:5
Text:CHARACTER:43.4
Insert
Type:INTEGER:5
Text:CHARACTER:SET refOutBody = InputRoot.JSON.Data;
RecoverableException
File:CHARACTER:F:\build\slot2\S1000_P\src\CommonServices\ImbConverter.cpp
Line:INTEGER:628
Function:CHARACTER:ImbConverterCPP::internalToUnicode
Type:CHARACTER:
Name:CHARACTER:
Label:CHARACTER:
Catalog:CHARACTER:BIPmsgs
Severity:INTEGER:3
Number:INTEGER:2135
Text:CHARACTER:Unconvertable character
Insert
Type:INTEGER:5
Text:CHARACTER:f8
Insert
Type:INTEGER:5
Text:CHARACTER:50f8ed6c699a209e6c759df375e86bfd204bf9f2
Insert
Type:INTEGER:2
Text:CHARACTER:1208
在我使用错误解析的 json 消息进行映射后抛出错误消息。
Soap-UI 这里有点棘手。
我的错误是在响应 Header 中发送了 Content-Type(正如 here 所回答的那样),但在那之后 Soap-UI 响应仍然采用与 UTF 不同的编码-8,即使 header 设置正确。
对于 UTF-8,您必须设置参数 JAVA_OPTS=-Dfile.encoding=UTF8
- in
<Soap-UI home>\bin\soapui.bat
(对于 .zip 版本) - 或
<Soap-UI home>\bin\SoapUI-5.4.0.vmoptions
(对于 .exe 版本)