marshalSendAndReceive () выдает «UnmarshallingFailureException» с «SAXParseException; cvc-elt.1: не удается найти объявление элемента» - PullRequest
0 голосов
/ 18 февраля 2019

Я пытаюсь вызвать сервис Soap из моего java-кода, я использую SpringBoot и maven.Я использовал maven-jaxb2-plugin и сгенерировал класс Java.Затем с помощью marshalSendAndReceive () я хочу получить ответ, но функция выдает ошибку "UnmarshallingFailureException: SAXParseException; cvc-elt.1: Не удается найти объявление элемента 'abc'".

когда я вызываю свою конечную точку, marshalSendAndReceive () выдает ошибку, у меня уже есть другая конфигурация marshallar, но ни одна не работает.

my xsd:

<xsd:element  name="GetFilterStatus" type="GetFilterStatusType" />

<xsd:element name="ReturnFilterStatus" type="ReturnFilterStatusType" />

<xsd:complexType name="GetFilterStatusType">
    <xsd:sequence>
        <xsd:element name="SchemaVersion" type="xsd:string"
            minOccurs="1" maxOccurs="1" />
        <xsd:element name="MessageHeader" type="message:MessageHeaderType"
            minOccurs="1" maxOccurs="1" />
        <xsd:element name="GetFilterStatusBody" minOccurs="1"
            maxOccurs="1">
            <xsd:complexType id="GetFilterStatusBodyType">
                <xsd:sequence>
                    <xsd:element name="EANReference" type="network:EANReferenceType"
                        minOccurs="1" maxOccurs="1" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ReturnFilterStatusType">
    <xsd:sequence>
        <xsd:element name="SchemaVersion" type="xsd:string"
            minOccurs="1" maxOccurs="1" />
        <xsd:element name="MessageHeader" type="message:MessageHeaderType"
            minOccurs="1" maxOccurs="1" />
        <xsd:element name="RefMessageIdentifier" type="message:MessageIdentifierType"
            minOccurs="1" maxOccurs="1" />
        <xsd:element name="Result" type="common:ResultType"
            minOccurs="1" maxOccurs="1" />
        <xsd:choice minOccurs="1" maxOccurs="1">
            <xsd:element name="Filters" type="network:FiltersType" />
            <xsd:element name="Errors" type="common:ErrorsType" />
        </xsd:choice>
    </xsd:sequence>
</xsd:complexType>   

мой клиент и маршаллер:

@Bean
public Client Client(Jaxb2Marshaller marshaller) {
    Client client = new Client();

    client.setDefaultUri("http://localhost:8080/ws");
    client.setMarshaller(marshaller);
    client.setUnmarshaller(marshaller);

    return client;
}


@Bean
public Jaxb2Marshaller marshaller() throws Exception {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

    marshaller.setCheckForXmlRootElement(false);
   marshaller.setSchema(new ClassPathResource("/xsd/docs/GetFilterStatus-
   v1_00.xsd"));
 marshaller.setSupportJaxbElementClass(true);

  marshaller.setPackagesToScan("ws.supplier.igs.operations.v1");
}

мой класс клиента:

  public class Client extends WebServiceGatewaySupport {

public JAXBElement<ReturnFilterStatusType> getFilterStatus (String url,JAXBElement<GetFilterStatusType> request,SoapActionCallback soapActionCallback) {


   JAXBElement<ReturnFilterStatusType> returnFilterStatusType= (JAXBElement<ReturnFilterStatusType>) (getWebServiceTemplate().marshalSendAndReceive(url,  request, soapActionCallback));


    return returnFilterStatusType;
}

я должен получить ответ, и он должен получить карту в моем классе

**Error that I'm getting:** 

org.springframework.oxm.UnmarshallingFailureException: исключение демаршаллинга JAXB;вложенным исключением является javax.xml.bind.UnmarshalException - со связанным исключением: [org.xml.sax.SAXParseException;cvc-elt.1: не удается найти объявление элемента ReturnFilterStatusType..java: 784)

...