【发布时间】:2018-10-12 12:32:23
【问题描述】:
我有一个端点来检查数据库中是否存在标识符并返回状态。将调用此端点的 USSD API。当我使用不存在的标识符 (EcNumber) 发出请求时,响应会按预期返回消息。但是,当我传递数据库中的标识符时,我也会获得相同的状态message.I 需要帮助来使用 isEmpty()/null 中的任何一个来实现相同的目的:
ClientEndpoint.java
@Endpoint
public class ClientEndpoint {
private static final String NAMESPACE_URI = "http://www.onewallet.org/webservices/disburse";
@Autowired
private IClientService clientService;
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getClientByEcNumRequest")
@ResponsePayload
public GetClienttByEcNumResponse getClient(@RequestPayload GetClientByEcNumRequest request) {
GetClienttByEcNumResponse response = new GetClienttByEcNumResponse();
ServiceStatus serviceStatus = new ServiceStatus();
ClientInfo clientInfo = new ClientInfo();
if ( clientInfo==null || clientInfo.getEcNumber()==null ){
serviceStatus.setMessage("EC# not registered with MCP");
} else {
BeanUtils.copyProperties(clientService.getClientByEcNumber(request.getEcNumber() ), clientInfo);
serviceStatus.setMessage("Welcome to MCP MobileLoans");
}
response.setServiceStatus(serviceStatus);
return response;
当我通过以下请求以获取有效的 EcNumber 时:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dis="http://www.onewallet.org/webservices/disburse">
<soapenv:Header/>
<soapenv:Body>
<dis:getClientByEcNumRequest>
<dis:ecNumber>5501900T</dis:ecNumber>
</dis:getClientByEcNumRequest>
</soapenv:Body>
</soapenv:Envelope>
我收到了回复:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:getClienttByEcNumResponse xmlns:ns2="http://www.onewallet.org/webservices/disburse">
<ns2:serviceStatus>
<ns2:message>EC# not registered with MCP</ns2:message>
</ns2:serviceStatus>
</ns2:getClienttByEcNumResponse>
【问题讨论】:
标签: spring-boot soap spring-data-jpa jax-ws