SOAPUI/Postman调用SOAP接口返回200但响应为空
SOAP调用CautareDosare接口返回空响应问题处理
问题现象
- 调用HelloWorld测试接口可正常接收预期响应,解析返回结果无异常
- 调用CautareDosare接口时返回HTTP 200状态码,链路传输无异常,但响应体无业务返回内容,
CautareDosareResponse节点为空 - 该问题在SOAPUI、Postman、基于easy-soap-request库的Node.js代码三种调用环境下复现结果完全一致
原始请求示例
请求基础配置:
POST http://portalquery.just.ro/Query.asmx?op=CautareDosare user-agent: portjust Content-Type: text/xml; charset=UTF-8 SOAPAction: portalquery.just.ro/CautareDosare
请求XML报文:
<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <CautareDosare xmlns="portalquery.just.ro"> <numarDosar>string</numarDosar> <!-- 该字段可空 --> <obiectDosar>string</obiectDosar> <!-- 该字段可空 --> <numeParte>mihaela</numeParte> <institutie>JudecatoriaARAD</institutie> <dataStart>2021-06-23T15:52:46.031Z</dataStart> <dataStop>2016-06-23T15:52:46.031Z</dataStop> </CautareDosare> </soap12:Body> </soap12:Envelope>
实际返回响应
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <CautareDosareResponse xmlns="portalquery.just.ro" /> </soap:Body> </soap:Envelope>
问题根因
请求存在两处参数错误,服务端匹配不到有效数据因此返回空响应节点:
- 时间区间参数逻辑倒置:
dataStart(查询开始时间)传值为2021-06-23,dataStop(查询结束时间)传值为2016-06-23,开始时间晚于结束时间,不存在符合该时间范围的案卷数据 - 可空字段传入无效占位值:
numarDosar、obiectDosar两个字段虽标注为可空,但请求中传入了示例占位文本string,服务端会将该文本作为有效查询条件做精确匹配,无法命中任何数据
修复方案
按以下规则调整请求参数即可正常获取返回结果:
- 调换两个时间参数的取值,保证查询开始时间早于结束时间
- 无需传值的可空字段直接留空节点内容,不要填入
string这类示例占位文本
修正后的请求XML报文参考:
<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <CautareDosare xmlns="portalquery.just.ro"> <numarDosar></numarDosar> <obiectDosar></obiectDosar> <numeParte>mihaela</numeParte> <institutie>JudecatoriaARAD</institutie> <dataStart>2016-06-23T15:52:46.031Z</dataStart> <dataStop>2021-06-23T15:52:46.031Z</dataStop> </CautareDosare> </soap12:Body> </soap12:Envelope>
内容的提问来源于stack exchange,提问作者Andrei F
相关产品推荐
相关产品推荐

