JAXB Fragment Marshal w/o namespace

前端 未结 3 818
时光说笑
时光说笑 2021-02-05 21:18

I\'m using the JAXB_FRAGMENT property for my marshaller to marshal at the WorkSet level. The problem is that when I marshal it\'s giving the WorkSet element the xmlns attribute

3条回答
  •  旧时难觅i
    2021-02-05 21:26

    Just another example:

        try {
            JAXBContext customerInformationRequestContext = JAXBContext.newInstance(CustomerInformationRequest.class);
            Unmarshaller unmarshaller = customerInformationRequestContext.createUnmarshaller();
            StringReader stringReader = new StringReader(requestPayload);
            XMLInputFactory xif = XMLInputFactory.newFactory();
            XMLStreamReader xsr = xif.createXMLStreamReader(stringReader);
            XMLStreamReaderWrapper reader = new XMLStreamReaderWrapper(xsr);
            CustomerInformationRequest customerInformationRequest = (CustomerInformationRequest) unmarshaller.unmarshal(reader);
            CustomerInformationResponse customerInformationResponse = customerLookup(customerInformationRequest, sessionTransaction);
            JAXBContext customerInformationResponseContext = JAXBContext.newInstance(CustomerInformationResponse.class);
            Marshaller marshaller = customerInformationResponseContext.createMarshaller();
            StringWriter stringWriter = new StringWriter();
            XMLOutputFactory xof = XMLOutputFactory.newFactory();
            XMLStreamWriter xsw = xof.createXMLStreamWriter(stringWriter);
            xsw = new XMLStreamWriterWrapper(xsw);
            marshaller.marshal(customerInformationResponse, xsw);
            String responsePayload = stringWriter.toString();
            return responsePayload;
        } catch (Exception e) {
            log.debug("The payload could not be unmarshalled.", e);
            return null;
        }
    

提交回复
热议问题