Проверьте, не возвращает ли объект ответа никаких данных - PullRequest
0 голосов
/ 12 октября 2018

У меня есть конечная точка, которая проверяет, существует ли идентификатор в базе данных, и возвращает статус.USSD API, который будет вызывать эту конечную точку. Когда я делаю запрос с несуществующим идентификатором (EcNumber), ответ возвращает сообщение, как я ожидаю. Однако, когда я передаю идентификатор, который находится в базе данных, я также получаю тот же статуссообщение. Мне нужна помощь в использовании любого из 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>

1 Ответ

0 голосов
/ 16 октября 2018

Понял.Я передаю неверный объект для проверки. Вместо экземпляра complexType (из определения схемы) следует использовать entity :

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "getClientByEcNumRequest")
    @ResponsePayload
    public GetClienttByEcNumResponse getClient(@RequestPayload GetClientByEcNumRequest request) {
        GetClienttByEcNumResponse response = new GetClienttByEcNumResponse();

    ServiceStatus serviceStatus = new ServiceStatus();
    **Client client=clientService.getClientByEcNumber(request.getEcNumber));**
    ClientInfo clientInfo = new ClientInfo();
    if ( client=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);
    response.setClientInfo(clientInfo)
    return response;
...