json - RestRequest - 特殊字符 - 发生 JSON 解析错误
问题描述
我有简单的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
我尝试了这个修复,但它不起作用:
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'application/json; charset=utf-8';
我什至尝试发送 SOAP-UI 标头Content-Type: application/json; charset=utf-8
我的属性和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
我认为这必须仍然是编码或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 (正如这里回答的那样),但之后 Soap-UI 响应仍然采用与 UTF-8 不同的编码,即使标题设置正确。
对于 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 版本)
推荐阅读
- rest - Apache camel Restlet 和 swagger 集成示例
- ruby - 用户输入的基本算术运算
- amazon-s3 - 调用 PutBucketAcl 操作时发生错误 (InvalidArgument):未知
- python - 无法在服务器上提供 Django 媒体文件?
- python - GPSD - 如何创建一个以纬度/经度为输入的虚拟 GPS 源
- php - 符合 ISO 3166-2 的 Google AdWords 位置标准 ID
- python-3.x - Python 3 neopixel 无功能
- user-interface - Unity滑块与控制器交互
- c++ - Qt Multimedia:未定义库“gstreamer”
- delphi - FastReport VCL Azure Web App 图片黑框