Использование REST API и получение кода ошибки 404 - PullRequest
0 голосов
/ 28 января 2020

Вот информация для моей службы REST.

Конечная точка https://spectrumcore.myCompany.com Ресурсы: / spectrum-core / services / customer / ept / getSoloIdentifiersV1x0

Здесь мой код.

package com.spectrum.biller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;



@SpringBootApplication
public class BillerApplication {

    private static final Logger log = LoggerFactory.getLogger(BillerApplication.class);

    public static void main(String[] args) {
        SpringApplication.run(BillerApplication.class, args);
    }



}

package com.spectrum.biller.controllers;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import com.spectrum.biller.exception.BillerException;
import com.spectrum.biller.model.SoloIdentifiersRequest;
import com.spectrum.biller.model.SoloIdentifiersResponse;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@RestController
@RequestMapping("/biller")
@ComponentScan("com.spectrum.biller")
public class BillerControllers {

    private static final Logger log = LoggerFactory.getLogger(BillerControllers.class);

    @Value("${biller.service.url}")
    private String billerServiceUrl;

    @GetMapping(value = "/soloIdentifiers", produces= {"application/json"})
    @ResponseBody
    public SoloIdentifiersResponse getSoloIdentifiers(
            //@ModelAttribute SoloIdentifiersRequest soloIdentifiersRequest 
            @RequestParam String systemID,
            @RequestParam String divisionID,
            @RequestParam String accountNumber
            ) {     
        try {
        RestTemplate restTemplate = new RestTemplate();
        SoloIdentifiersRequest soloIdentifiersRequest = new SoloIdentifiersRequest();
        soloIdentifiersRequest.setSystemID(systemID);
        soloIdentifiersRequest.setDivisionID(divisionID);
        soloIdentifiersRequest.setAccountNumber(accountNumber);
        SoloIdentifiersResponse soloIdentifiersResponse = 
                restTemplate.getForObject(billerServiceUrl, SoloIdentifiersResponse.class, soloIdentifiersRequest);
        return soloIdentifiersResponse;
        } catch ( Exception e) {
            throw new BillerException("Error in Biller Client " + e.getMessage() + e);
        }
    } 

}


My application.yml file 

server:
   port : 8080

biller.service:
  url: https://spectrumcore.myCompany.com/spectrum-core/services/customer/ept/getSoloIdentifiersV1x0

package com.spectrum.biller.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties
public class SoloIdentifiersRequest {

    private String systemID;
    private String divisionID;
    private String accountNumber;

    public String getSystemID() {
        return systemID;
    }
    public void setSystemID(String systemID) {
        this.systemID = systemID;
    }
    public String getDivisionID() {
        return divisionID;
    }
    public void setDivisionID(String divisionID) {
        this.divisionID = divisionID;
    }
    public String getAccountNumber() {
        return accountNumber;
    }
    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }

    @Override
    public String toString() {
        return "SoloIdentifiersRequest [systemID=" + systemID + ", divisionID=" + divisionID + ", accountNumber="
                + accountNumber + "]";
    }

}


package com.spectrum.biller.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties
public class SoloIdentifiersResponse {

    private String uCAN;
    private String divisionID;
    private String accountNumber;
    private String locationNumber;
    private String customerNumber;
    private String soloAccountNumber;
    private String soloLocationNumber;
    private String soloPartyID;
    private String billingStationLevel1Code;
    private String billingStationLevel2Code;
    private String billingStationID;
    private String sourceFTACode;

    public String getuCAN() {
        return uCAN;
    }
    public void setuCAN(String uCAN) {
        this.uCAN = uCAN;
    }
    public String getDivisionID() {
        return divisionID;
    }
    public void setDivisionID(String divisionID) {
        this.divisionID = divisionID;
    }
    public String getAccountNumber() {
        return accountNumber;
    }
    public void setAccountNumber(String accountNumber) {
        this.accountNumber = accountNumber;
    }
    public String getLocationNumber() {
        return locationNumber;
    }
    public void setLocationNumber(String locationNumber) {
        this.locationNumber = locationNumber;
    }
    public String getCustomerNumber() {
        return customerNumber;
    }
    public void setCustomerNumber(String customerNumber) {
        this.customerNumber = customerNumber;
    }
    public String getSoloAccountNumber() {
        return soloAccountNumber;
    }
    public void setSoloAccountNumber(String soloAccountNumber) {
        this.soloAccountNumber = soloAccountNumber;
    }
    public String getSoloLocationNumber() {
        return soloLocationNumber;
    }
    public void setSoloLocationNumber(String soloLocationNumber) {
        this.soloLocationNumber = soloLocationNumber;
    }
    public String getSoloPartyID() {
        return soloPartyID;
    }
    public void setSoloPartyID(String soloPartyID) {
        this.soloPartyID = soloPartyID;
    }
    public String getBillingStationLevel1Code() {
        return billingStationLevel1Code;
    }
    public void setBillingStationLevel1Code(String billingStationLevel1Code) {
        this.billingStationLevel1Code = billingStationLevel1Code;
    }
    public String getBillingStationLevel2Code() {
        return billingStationLevel2Code;
    }
    public void setBillingStationLevel2Code(String billingStationLevel2Code) {
        this.billingStationLevel2Code = billingStationLevel2Code;
    }
    public String getBillingStationID() {
        return billingStationID;
    }
    public void setBillingStationID(String billingStationID) {
        this.billingStationID = billingStationID;
    }
    public String getSourceFTACode() {
        return sourceFTACode;
    }
    public void setSourceFTACode(String sourceFTACode) {
        this.sourceFTACode = sourceFTACode;
    }
    @Override
    public String toString() {
        return "SoloIdentifiersResponse [uCAN=" + uCAN + ", divisionID=" + divisionID + ", accountNumber="
                + accountNumber + ", locationNumber=" + locationNumber + ", customerNumber=" + customerNumber
                + ", soloAccountNumber=" + soloAccountNumber + ", soloLocationNumber=" + soloLocationNumber
                + ", soloPartyID=" + soloPartyID + ", billingStationLevel1Code=" + billingStationLevel1Code
                + ", billingStationLevel2Code=" + billingStationLevel2Code + ", billingStationID=" + billingStationID
                + ", sourceFTACode=" + sourceFTACode + "]";
    }

}


My url to test the app.

http://localhost:8080/biller/soloIdentifiers?systemID=ProvSvcs&divisionID=LBT.8150&accountNumber=8150300010008485

Я получаю

Страница ошибки Whitelabel Это приложение не имеет явного сопоставления для / error, поэтому вы видите это как запасной вариант.

Mon 27 января 15:18:19 MST 2020 Произошла непредвиденная ошибка (тип = Внутренняя ошибка сервера, статус = 500). Ошибка в Biller Client 400: [{"errorResponse": {"errors": [{"code": "1000", "description": "Исключительная ситуация недопустимого запроса", "source": "SPECTRUM_CORE"}]}}}] org .springframework.web.client.HttpClientErrorException $ BadRequest: 400: [{"errorResponse": {"errors": [{"code": "1000", "description": "Исключительная ситуация недопустимого запроса", "source": "SPECTRUM_CORE "}]}}]

Вот входные данные, которые я добавляю в soapUI, а также получаю ответ ниже.

                   <GetSoloIdentifiersRequest> 
<systemID>ProvSvcs</systemID> 
<divisionID>LBT.8150</divisionID> 
<accountNumber>8150300010008485</accountNumber>
</GetSoloIdentifiersRequest>             <getSoloIdentifiersResponse>
   <uCAN>57922705670</uCAN>
   <divisionID>LBT.8150</divisionID>
   <accountNumber>8150300010008485</accountNumber>
   <locationNumber>10992150205033</locationNumber>
   <customerNumber>1104018630888</customerNumber>
   <soloAccountNumber>71694273</soloAccountNumber>
   <soloLocationNumber>235342534</soloLocationNumber>
   <soloPartyID>55379641</soloPartyID>
   <billingStationLevel1Code>8150</billingStationLevel1Code>
   <billingStationLevel2Code>3000</billingStationLevel2Code>
   <billingStationID>32455613</billingStationID>
   <sourceFTACode>0010</sourceFTACode>
</getSoloIdentifiersResponse>               
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...