Search in sources :

Example 1 with ValueType

use of whitebox.message.source.types.ValueType in project metro-jax-ws by eclipse-ee4j.

the class SourceMessageTester method testSOAP11MessageAsJAXB.

public void testSOAP11MessageAsJAXB() {
    try {
        Message msg = createPayloadSourceMessage();
        HeaderList hl = msg.getHeaders();
        JAXBContext ctxt = null;
        Unmarshaller unmarshaller = null;
        try {
            ctxt = JAXBContext.newInstance("whitebox.message.source.types");
            unmarshaller = ctxt.createUnmarshaller();
        } catch (JAXBException e) {
            e.printStackTrace();
            assertTrue(false);
        }
        int i = 0;
        // validate the headers form unmarshalled jaxb bean
        for (Header h : hl) {
            assertTrue(validateHeader(h, unmarshaller, headers[i++], SOAPVersion.SOAP_11));
        }
        // validate body
        assertTrue(msg.getPayloadLocalPart().equals("Body") && msg.getPayloadNamespaceURI().equals("urn:test:types"));
        JAXBElement<ValueType> body = msg.readPayloadAsJAXB(unmarshaller);
        assertTrue(body.getValue().getValue().equals("Its Body"));
    } catch (JAXBException e) {
        e.printStackTrace();
        assertTrue(false);
    }
}
Also used : Message(com.sun.xml.ws.api.message.Message) PayloadSourceMessage(com.sun.xml.ws.message.source.PayloadSourceMessage) Header(com.sun.xml.ws.api.message.Header) ValueType(whitebox.message.source.types.ValueType) HeaderList(com.sun.xml.ws.api.message.HeaderList) JAXBException(jakarta.xml.bind.JAXBException) JAXBContext(jakarta.xml.bind.JAXBContext) Unmarshaller(jakarta.xml.bind.Unmarshaller)

Aggregations

Header (com.sun.xml.ws.api.message.Header)1 HeaderList (com.sun.xml.ws.api.message.HeaderList)1 Message (com.sun.xml.ws.api.message.Message)1 PayloadSourceMessage (com.sun.xml.ws.message.source.PayloadSourceMessage)1 JAXBContext (jakarta.xml.bind.JAXBContext)1 JAXBException (jakarta.xml.bind.JAXBException)1 Unmarshaller (jakarta.xml.bind.Unmarshaller)1 ValueType (whitebox.message.source.types.ValueType)1