org.apache.cxf.interceptor.StaxOutInterceptor Java Examples

The following examples show how to use org.apache.cxf.interceptor.StaxOutInterceptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLGetOutInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void handleMessage(Message message) throws Fault {
    Document doc = (Document)message.get(WSDLGetInterceptor.DOCUMENT_HOLDER);
    if (doc == null) {
        return;
    }
    message.remove(WSDLGetInterceptor.DOCUMENT_HOLDER);

    XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
    if (writer == null) {
        return;
    }
    message.put(Message.CONTENT_TYPE, "text/xml");
    try {
        StaxUtils.writeDocument(doc, writer,
                                !MessageUtils.getContextualBoolean(message,
                                                                   StaxOutInterceptor.FORCE_START_DOCUMENT,
                                                                   false),
                                true);
    } catch (XMLStreamException e) {
        throw new Fault(e);
    }
}
 
Example #2
Source File: XMLBindingFactory.java    From cxf with Apache License 2.0 6 votes vote down vote up
public Binding createBinding(BindingInfo binding) {
    XMLBinding xb = new XMLBinding(binding);

    xb.getInInterceptors().add(new AttachmentInInterceptor());
    xb.getInInterceptors().add(new StaxInInterceptor());
    xb.getInInterceptors().add(new DocLiteralInInterceptor());
    xb.getInInterceptors().add(new XMLMessageInInterceptor());

    xb.getOutInterceptors().add(new AttachmentOutInterceptor());
    xb.getOutInterceptors().add(new StaxOutInterceptor());
    xb.getOutInterceptors().add(new WrappedOutInterceptor());
    xb.getOutInterceptors().add(new XMLMessageOutInterceptor());

    xb.getInFaultInterceptors().add(new XMLFaultInInterceptor());
    xb.getOutFaultInterceptors().add(new StaxOutInterceptor());
    xb.getOutFaultInterceptors().add(new XMLFaultOutInterceptor());

    return xb;
}
 
Example #3
Source File: WSDLGetInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void cleanUpOutInterceptors(Message outMessage) {
    // TODO - how can I improve this to provide a specific interceptor chain that just has the
    // stax, gzip and message sender components, while also ensuring that GZIP is only provided
    // if its already configured for the endpoint.
    Iterator<Interceptor<? extends Message>> iterator = outMessage.getInterceptorChain().iterator();
    while (iterator.hasNext()) {
        Interceptor<? extends Message> inInterceptor = iterator.next();
        if (!inInterceptor.getClass().equals(StaxOutInterceptor.class)
                && !inInterceptor.getClass().equals(GZIPOutInterceptor.class)
                && !inInterceptor.getClass().equals(MessageSenderInterceptor.class)) {
            outMessage.getInterceptorChain().remove(inInterceptor);
        }
    }

}
 
Example #4
Source File: WSS4JStaxOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public WSS4JStaxOutInterceptor(WSSSecurityProperties securityProperties) {
    super(securityProperties);
    WSSec.init();
    setPhase(Phase.PRE_STREAM);
    getBefore().add(StaxOutInterceptor.class.getName());
    getAfter().add("org.apache.cxf.interceptor.LoggingOutInterceptor");
    getAfter().add("org.apache.cxf.ext.logging.LoggingOutInterceptor");
    ending = createEndingInterceptor();
}
 
Example #5
Source File: WSS4JStaxOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public WSS4JStaxOutInterceptor(Map<String, Object> props) {
    super(props);
    WSSec.init();
    setPhase(Phase.PRE_STREAM);
    getBefore().add(StaxOutInterceptor.class.getName());
    getAfter().add("org.apache.cxf.interceptor.LoggingOutInterceptor");
    getAfter().add("org.apache.cxf.ext.logging.LoggingOutInterceptor");
    ending = createEndingInterceptor();
}
 
Example #6
Source File: WSS4JStaxOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public WSS4JStaxOutInterceptor() {
    super();
    WSSec.init();
    setPhase(Phase.PRE_STREAM);
    getBefore().add(StaxOutInterceptor.class.getName());
    getAfter().add("org.apache.cxf.interceptor.LoggingOutInterceptor");
    getAfter().add("org.apache.cxf.ext.logging.LoggingOutInterceptor");
    ending = createEndingInterceptor();
}
 
Example #7
Source File: LoggingOutInterceptor.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
public LoggingOutInterceptor ()
{
   super (Phase.PRE_STREAM);
   addBefore (StaxOutInterceptor.class.getName ());
}
 
Example #8
Source File: XMLDeclarationWritingInterceptor.java    From juddi with Apache License 2.0 4 votes vote down vote up
public XMLDeclarationWritingInterceptor () { 
    super(Phase.PRE_STREAM); 
    addBefore(StaxOutInterceptor.class.getName());
}
 
Example #9
Source File: WSDLGetOutInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public WSDLGetOutInterceptor() {
    super(Phase.PRE_STREAM);
    getAfter().add(StaxOutInterceptor.class.getName());
}
 
Example #10
Source File: JAXRSDefaultFaultOutInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void handleMessage(Message message) throws Fault {
    if (PropertyUtils.isTrue(message.getExchange().get(JAXRSUtils.SECOND_JAXRS_EXCEPTION))) {
        return;
    }
    final Fault f = (Fault) message.getContent(Exception.class);

    Response r = JAXRSUtils.convertFaultToResponse(f.getCause(), message);
    if (r != null) {
        JAXRSUtils.setMessageContentType(message, r);
        message.setContent(List.class, new MessageContentsList(r));
        if (message.getExchange().getOutMessage() == null && message.getExchange().getOutFaultMessage() != null) {
            message.getExchange().setOutMessage(message.getExchange().getOutFaultMessage());
        }
        new JAXRSOutInterceptor().handleMessage(message);
        return;
    }

    ServerProviderFactory.releaseRequestState(message);
    if (mustPropogateException(message)) {
        throw f;
    }

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

    XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
    try {
        nsStack.add("http://cxf.apache.org/bindings/xformat");
        String prefix = nsStack.getPrefix("http://cxf.apache.org/bindings/xformat");
        StaxUtils.writeStartElement(writer, prefix, "XMLFault",
                                    "http://cxf.apache.org/bindings/xformat");
        StaxUtils.writeStartElement(writer, prefix, "faultstring",
                                    "http://cxf.apache.org/bindings/xformat");
        Throwable t = f.getCause();
        writer.writeCharacters(t == null ? f.getMessage() : t.toString());
        // fault string
        writer.writeEndElement();
        // call StaxUtils to write Fault detail.

        if (f.getDetail() != null) {
            StaxUtils.writeStartElement(writer, prefix, "detail", "http://cxf.apache.org/bindings/xformat");
            StaxUtils.writeNode(DOMUtils.getChild(f.getDetail(), Node.ELEMENT_NODE),
                                writer, false);
            writer.writeEndElement();
        }
        // fault root
        writer.writeEndElement();
        writer.flush();
    } catch (XMLStreamException xe) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("XML_WRITE_EXC", BUNDLE), xe);
    }
}
 
Example #11
Source File: LoggingOutInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public LoggingOutInterceptor(LogEventSender sender) {
    super(Phase.PRE_STREAM, sender);
    addBefore(StaxOutInterceptor.class.getName());
}
 
Example #12
Source File: XmlSecOutInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public XmlSecOutInterceptor() {
    super(Phase.PRE_STREAM);
    getBefore().add(StaxOutInterceptor.class.getName());

    ending = createEndingInterceptor();
}
 
Example #13
Source File: XSLTOutInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public XSLTOutInterceptor(String xsltPath) {
    super(Phase.PRE_STREAM, StaxOutInterceptor.class, null, xsltPath);
}
 
Example #14
Source File: TransformOutInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public TransformOutInterceptor(String phase) {
    super(phase);
    addBefore(StaxOutInterceptor.class.getName());
    addAfter("org.apache.cxf.interceptor.LoggingOutInterceptor");
    addAfter("org.apache.cxf.ext.logging.LoggingOutInterceptor");
}