Передача части xml в @XmlAnyElement - PullRequest
0 голосов
/ 14 февраля 2020

Вот мой класс createOrder. В сообщении я передаю сообщение xml, как показано ниже. Перед отправкой ниже xml я встраиваю тэг msg begin и end. Но я получаю все сообщения журнала ниже как ноль.

            <head>
               <Routing>8260|1700|0540</Routing>          
            </head>
            <body>
                  <Business>
                     <BusinessUnit>0</BusinessUnit>
                  </Business>
           </body>

public CreateOrderResponseType createOrder(String message) {
        log.info("Entering createOrder for OSMClient..." );

        CreateOrderRequestType createOrderRequestType = new CreateOrderRequestType();
        Document doc;
        try {
            doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
            Element msg = doc.createElement("msg");
            msg.setTextContent(message);
            log.info("msg = " + msg);
            doc.appendChild(msg);
            log.info("doc = " + doc.toString());
            log.info("doc firstChild = " + doc.getFirstChild().toString());
            createOrderRequestType.getAny().add((Element) doc.getFirstChild());

            JAXBContext jc = JAXBContext.newInstance(CreateOrderRequestType.class);
            Marshaller marshaller = jc.createMarshaller();
            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
            marshaller.marshal(createOrderRequestType, System.out); 

        } catch (ParserConfigurationException e2) {
            // TODO Auto-generated catch block
            e2.printStackTrace();
        } catch (JAXBException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

Может кто-нибудь помочь мне, почему я получаю нулевые значения?

...