Examples of XMLFault


Examples of org.apache.axis2.jaxws.message.XMLFault

        MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        SOAPMessage sm = mf.createMessage();
        SOAPBody body = sm.getSOAPBody();
        SOAPFault fault = body.addFault(CUSTOM, "Custom Fault");
       
        XMLFault xmlFault = XMLFaultUtils.createXMLFault(fault);
       
        assertTrue(xmlFault != null);
       
        XMLFaultReason reason = xmlFault.getReason();
        assertTrue(reason != null);
        assertTrue(reason.getText().equals("Custom Fault"));
       
        XMLFaultCode code = xmlFault.getCode();
        assertTrue(code != null);
       
        QName codeQName = code.toQName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE);
        assertTrue("Expected QName = " + CUSTOM + " but received = " + codeQName, codeQName.equals(CUSTOM));
                       
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

            reader.nextTag();
            if (!StaxUtils.toNextElement(reader)) {
                throw new Fault(new org.apache.cxf.common.i18n.Message("ILLEGAL_XMLFAULT_FORMAT", BUNDLE));
            }
            String exMessage = reader.getElementText();
            Fault fault = new XMLFault(exMessage);
            reader.nextTag();
            if (StaxUtils.toNextElement(reader)) {
                // handling detail
                Element detail = StaxUtils.read(new FragmentStreamReader(reader)).getDocumentElement();
                fault.setDetail(detail);
            }
            message.setContent(Exception.class, fault);
        } catch (XMLStreamException xse) {
            throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", BUNDLE));
        }
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

        message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode());
        NSStack nsStack = new NSStack();
        nsStack.push();

        XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
        XMLFault xmlFault = XMLFault.createFault(f);
        try {
            nsStack.add(XMLConstants.NS_XML_FORMAT);
            String prefix = nsStack.getPrefix(XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_ROOT,
                    XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING,
                    XMLConstants.NS_XML_FORMAT);
            Throwable t = xmlFault.getCause();
            writer.writeCharacters(t == null ? xmlFault.getMessage() : t.toString());
            // fault string
            writer.writeEndElement();
            // call StaxUtils to write Fault detail.
           
            if (xmlFault.getDetail() != null) {
                StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL,
                        XMLConstants.NS_XML_FORMAT);
                StaxUtils.writeNode(DOMUtils.getChild(xmlFault.getDetail(), Node.ELEMENT_NODE),
                                    writer, false);
                writer.writeEndElement();
            }
            // fault root
            writer.writeEndElement();
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

        message.put(org.apache.cxf.message.Message.RESPONSE_CODE, f.getStatusCode());
        NSStack nsStack = new NSStack();
        nsStack.push();

        XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
        XMLFault xmlFault = XMLFault.createFault(f);
        try {
            nsStack.add(XMLConstants.NS_XML_FORMAT);
            String prefix = nsStack.getPrefix(XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_ROOT,
                    XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING,
                    XMLConstants.NS_XML_FORMAT);
            Throwable t = xmlFault.getCause();
            writer.writeCharacters(t == null ? xmlFault.getMessage() : t.toString());
            // fault string
            writer.writeEndElement();
            // call StaxUtils to write Fault detail.
           
            if (xmlFault.getDetail() != null) {
                Element detail = xmlFault.getDetail();
                StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL,
                        XMLConstants.NS_XML_FORMAT);
               
                Node node = detail.getFirstChild();
                while (node != null) {
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

            reader.nextTag();
            if (!StaxUtils.toNextElement(reader)) {
                throw new Fault(new org.apache.cxf.common.i18n.Message("ILLEAGAL_XMLFAULT_FORMAT", BUNDLE));
            }
            String exMessage = reader.getElementText();
            Fault fault = new XMLFault(exMessage);
            reader.nextTag();
            if (StaxUtils.toNextElement(reader)) {
                // handling detail
                Element detail = StaxUtils.read(new FragmentStreamReader(reader)).getDocumentElement();
                fault.setDetail(detail);
            }
            message.setContent(Exception.class, fault);
        } catch (XMLStreamException xse) {
            throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC", BUNDLE));
        }
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

        NSStack nsStack = new NSStack();
        nsStack.push();

        XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
        Fault f = (Fault) message.getContent(Exception.class);
        XMLFault xmlFault = XMLFault.createFault(f);
        try {
            nsStack.add(XMLConstants.NS_XML_FORMAT);
            String prefix = nsStack.getPrefix(XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_ROOT,
                    XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING,
                    XMLConstants.NS_XML_FORMAT);
            Throwable t = xmlFault.getCause();
            writer.writeCharacters(t == null ? xmlFault.getMessage() : t.toString());
            // fault string
            writer.writeEndElement();
            // call StaxUtils to write Fault detail.
           
            if (xmlFault.getDetail() != null) {
                StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL,
                        XMLConstants.NS_XML_FORMAT);
                StaxUtils.writeNode(DOMUtils.getChild(xmlFault.getDetail(), Node.ELEMENT_NODE),
                                    writer, false);
                writer.writeEndElement();
            }
            // fault root
            writer.writeEndElement();
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

        FaultDetail detail = new FaultDetail();
        detail.setMajor((short)2);
        detail.setMinor((short)1);
        PingMeFault fault = new PingMeFault("TEST_FAULT", detail);

        XMLFault xmlFault = XMLFault.createFault(new Fault(fault));
        Element el = xmlFault.getOrCreateDetail();
        JAXBContext ctx = JAXBContext.newInstance(FaultDetail.class);
        Marshaller m = ctx.createMarshaller();
        m.marshal(detail, el);
       
        OutputStream outputStream = new ByteArrayOutputStream();
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

        chain.add(cfc);
        chain.add(xfi);
        chain.doIntercept(xmlMessage);
        assertNotNull(xmlMessage.getContent(Exception.class));
        assertTrue(xmlMessage.getContent(Exception.class) instanceof XMLFault);
        XMLFault xfault = (XMLFault) xmlMessage.getContent(Exception.class);
        assertTrue("check message expected - dummy exception",
                xfault.getMessage().indexOf("dummy exception") >= 0);
    }
View Full Code Here

Examples of org.apache.cxf.binding.xml.XMLFault

        NSStack nsStack = new NSStack();
        nsStack.push();

        XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
        Fault f = (Fault) message.getContent(Exception.class);
        XMLFault xmlFault = XMLFault.createFault(f);
        try {
            nsStack.add(XMLConstants.NS_XML_FORMAT);
            String prefix = nsStack.getPrefix(XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_ROOT,
                    XMLConstants.NS_XML_FORMAT);
            StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_STRING,
                    XMLConstants.NS_XML_FORMAT);
            Throwable t = xmlFault.getCause();
            writer.writeCharacters(t == null ? xmlFault.getMessage() : t.toString());
            // fault string
            writer.writeEndElement();
            // call StaxUtils to write Fault detail.
           
            if (xmlFault.getDetail() != null) {
                StaxUtils.writeStartElement(writer, prefix, XMLFault.XML_FAULT_DETAIL,
                        XMLConstants.NS_XML_FORMAT);
                StaxUtils.writeNode(DOMUtils.getChild(xmlFault.getDetail(), Node.ELEMENT_NODE),
                                    writer, false);
                writer.writeEndElement();
            }
            // fault root
            writer.writeEndElement();
View Full Code Here

Examples of org.objectweb.celtix.bus.bindings.xml.XMLFault

        }
    }
    public void write(Object obj, QName elName, T output) {
        Object faultInfo = getFaultInfo((Throwable)obj);
        if (faultInfo != null) {
            XMLFault fault = (XMLFault)output;
            Node detail = fault.addFaultDetail();
            JAXBEncoderDecoder.marshall(callback.getJAXBContext(),
                callback.getSchema(), faultInfo, elName, detail);
            fault.setFaultDetail(detail);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.