Получение ошибки HttpMessageConversionException - PullRequest
0 голосов
/ 30 января 2020

Вот мой URL для транзакции POST.

http://localhost: 8080 / uim / createHsdService

Here is the body I supplied in Postman.
{
 "name":"35936825_69095406_000145",
 "characteristics":{"name":"characteristics",
                   "declaredType":"com.chartercom.xmlns.sdp.uim.webservice.invextension.CharacteristicListType",
                   "scope":"com.chartercom.xmlns.sdp.uim.webservice.service.ServiceDataType",
                   "value":{"characteristic":[
                   {
                   "name":"USOCCode",
                   "value":"DLC705"
                   }
                   ]}
                   }
 }

Then here is my client code.

@PostMapping("/createHsdService")
    @ResponseBody
    public void createHsdService(@RequestBody com.spectrum.uim.model.Service service) {

        log.debug("Entering createHsdService...");

        log.debug("Trying to print service input = " + service.toString());

        ObjectFactory factory = new ObjectFactory();
        ServiceDataType serviceDataType = new ServiceDataType(); 

        DesignServiceRequestType designServiceRequestType = new DesignServiceRequestType();


        JAXBElement<CharacteristicListType>  characteristicListType= factory.createServiceDataTypeCharacteristics(service.getCharacteristics());


        log.debug("Service name = " + service.getName());
        serviceDataType.setName(service.getName());
        serviceDataType.setSpecification(specification);
        serviceDataType.setAction(ActionType.COMPLETE);


        log.debug("characteristicListType Name= " + service.getCharacteristics().getCharacteristic());


        serviceDataType.setCharacteristics(characteristicListType);
        designServiceRequestType.setService(serviceDataType); 


        log.debug("Request for createHsdService = " + designServiceRequestType.toString());

        uimService.designService(designServiceRequestType);
    }


Here is ServiceDataType class.

public class ServiceDataType
    extends CharterEntityType
{

    @XmlElement(required = true)
    protected String name;
    protected String description;
    @XmlElement(required = true)
    protected String specification;
    @XmlElement(required = true, nillable = true)
    @XmlSchemaType(name = "string")
    protected ServiceStateType state;
    @XmlElementRef(name = "characteristics", type = JAXBElement.class, required = false)
    protected JAXBElement<CharacteristicListType> characteristics;
    protected FeatureListType featureList;
    protected NameListType equipments;
    protected String servicePort;
    @XmlSchemaType(name = "string")
    protected ActionType action;

Here is CharacteristicListType class.

public class CharacteristicListType
    extends CharterEntityListType
{

    protected List<CharacteristicListType.Characteristic> characteristic;


      public List<CharacteristicListType.Characteristic> getCharacteristic() {
        if (characteristic == null) {
            characteristic = new ArrayList<CharacteristicListType.Characteristic>();
        }
        return this.characteristic;
    }

   @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "")
    public static class Characteristic {

        @XmlAttribute(name = "name")
        protected String name;
        @XmlAttribute(name = "value")
        protected String value;



Then I created a Service.class to mimic ServiceDataType class except I changed the JAXBElement<CharacteristicListType> to simply CharacteristicListType

@Getter
@Setter
@ToString
public class Service {
        @JsonProperty("name")
        protected String name;
        @JsonProperty("description")
        protected String description;

        @JsonProperty("specification")
        protected String specification;
        @JsonProperty("state")
        protected ServiceStateType state;
        @JsonProperty("characteristics")
        protected CharacteristicListType characteristics;
        @JsonProperty("featureList")
        protected FeatureListType featureList;
        @JsonProperty("equipments")
        protected NameListType equipments;
        @JsonProperty("servicePort")
        protected String servicePort;
        @JsonProperty("action")
        protected ActionType action;

}

Я получаю ошибку, как показано ниже от почтальона { «отметка времени»: «2020-01-30T22: 58: 08.356 + 0000», «состояние»: 500, «ошибка»: «Внутренняя ошибка сервера», «сообщение»: «Ошибка инвентаризации UIM для designService с кодом ошибки = 130021 Ошибка» Message = Characteristi c USOCCode - обязательное поле. "," Path ":" / uim / createHsdService "}

Now, I am not able to figure out how to read json data {
                   "name":"USOCCode",
                   "value":"DLC705"
                   } as i provided in PayLoad.


Thanks
Bandita Pradhan




...