1

I am trying to consume a web service using JAX-WS, and it throws me the following error corresponding to the following classes: Class 1

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "validarComprobante", propOrder = { "xml" })
public class ValidarComprobante {

    protected byte[] xml;

    public byte[] getXml() {
        return xml;
    }

    public void setXml(byte[] value) {
        this.xml = value;
    }

}

Class 2

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "validarComprobanteResponse", propOrder = { "respuestaRecepcionComprobante" })
public class ValidarComprobanteResponse {

    @XmlElement(name = "RespuestaRecepcionComprobante")
    protected RespuestaSolicitud respuestaRecepcionComprobante;

    public RespuestaSolicitud getRespuestaRecepcionComprobante() {
        return respuestaRecepcionComprobante;
    }

    public void setRespuestaRecepcionComprobante(RespuestaSolicitud value) {
        this.respuestaRecepcionComprobante = value;
    }

}

These classes were generated with wsimport.exe which is inside the Java 8 SDK. The error is as follows:

com.sun.xml.ws.spi.db.DatabindingException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://ec.gob.sri.ws.recepcion}validarComprobante". Use @XmlType.name and @XmlType.namespace to assign different names to them.
        this problem is related to the following location:
            at com.horus.microservices.ebillinginvoice.sri.recepcion.ValidarComprobante
            at public javax.xml.bind.JAXBElement com.horus.microservices.ebillinginvoice.sri.recepcion.ObjectFactory.createValidarComprobante(com.horus.microservices.ebillinginvoice.sri.recepcion.ValidarComprobante)
            at com.horus.microservices.ebillinginvoice.sri.recepcion.ObjectFactory
        this problem is related to the following location:
            at recepcion.ws.sri.gob.ec.ValidarComprobante
    Two classes have the same XML type name "{http://ec.gob.sri.ws.recepcion}validarComprobanteResponse". Use @XmlType.name and @XmlType.namespace to assign different names to them.
        this problem is related to the following location:
            at com.horus.microservices.ebillinginvoice.sri.recepcion.ValidarComprobanteResp
            at public com.horus.microservices.ebillinginvoice.sri.recepcion.ValidarComprobanteResp com.horus.microservices.ebillinginvoice.sri.recepcion.ObjectFactory.createValidarComprobanteResponse()
            at com.horus.microservices.ebillinginvoice.sri.recepcion.ObjectFactory
        this problem is related to the following location:
            at recepcion.ws.sri.gob.ec.ValidarComprobanteResponse

        at com.sun.xml.ws.db.glassfish.JAXBRIContextFactory.newContext(JAXBRIContextFactory.java:105)
        at 

Please any help Thanks

Yus
  • 11
  • 1
  • 1
  • 4
  • Hi interesting, perhaps this is of interest https://stackoverflow.com/questions/19132789/getting-the-jaxb-exception-like-two-classes-have-the-same-xml-type-name – IronMan Jun 01 '20 at 21:32

0 Answers0