Search in sources :

Example 31 with MessageContentsList

use of org.apache.cxf.message.MessageContentsList in project cxf by apache.

the class HTTPConduitURLEasyMockTest method createMessage.

private Message createMessage() {
    Message message = new MessageImpl();
    message.put("Content-Type", "text/xml;charset=utf8");
    message.setContent(List.class, new MessageContentsList("<body/>"));
    return message;
}
Also used : Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) MessageImpl(org.apache.cxf.message.MessageImpl)

Example 32 with MessageContentsList

use of org.apache.cxf.message.MessageContentsList in project cxf by apache.

the class CustomJAXRSInvoker method invoke.

@Override
public Object invoke(Exchange exchange, Object requestParams, Object resourceObject) {
    OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
    Method m = ori.getMethodToInvoke();
    Class<?> realClass = ClassHelper.getRealClass(exchange.getBus(), resourceObject);
    Principal p = new SecurityContextImpl(exchange.getInMessage()).getUserPrincipal();
    if (realClass == SecureBookStore.class && "getThatBook".equals(m.getName()) && "baddy".equals(p.getName())) {
        return new MessageContentsList(Response.status(Response.Status.FORBIDDEN).build());
    }
    return super.invoke(exchange, requestParams, resourceObject);
}
Also used : SecurityContextImpl(org.apache.cxf.jaxrs.impl.SecurityContextImpl) MessageContentsList(org.apache.cxf.message.MessageContentsList) OperationResourceInfo(org.apache.cxf.jaxrs.model.OperationResourceInfo) Method(java.lang.reflect.Method) Principal(java.security.Principal)

Example 33 with MessageContentsList

use of org.apache.cxf.message.MessageContentsList in project cxf by apache.

the class ServantTest method createTestCreateSequenceMessage.

private static Message createTestCreateSequenceMessage(Expires expires, OfferType offer) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);
    // exchange.setOutMessage(new MessageImpl());
    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getCreateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    CreateSequenceType cs = new CreateSequenceType();
    cs.setAcksTo(org.apache.cxf.ws.addressing.VersionTransformer.convert(RMUtils.createReference(DECOUPLED_URL)));
    cs.setExpires(expires);
    cs.setOffer(offer);
    MessageContentsList contents = new MessageContentsList();
    contents.add(cs);
    message.setContent(List.class, contents);
    RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM10WSA200408);
    return message;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) CreateSequenceType(org.apache.cxf.ws.rm.v200502.CreateSequenceType) MessageContentsList(org.apache.cxf.message.MessageContentsList) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 34 with MessageContentsList

use of org.apache.cxf.message.MessageContentsList in project cxf by apache.

the class ServantTest method createTestTerminateSequenceMessage.

private static Message createTestTerminateSequenceMessage(String sidstr, ProtocolVariation protocol) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);
    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    TerminateSequenceType ts = new TerminateSequenceType();
    Identifier sid = new Identifier();
    sid.setValue(sidstr);
    ts.setIdentifier(sid);
    Object tst = ProtocolVariation.RM10WSA200408.getWSRMNamespace().equals(protocol.getWSRMNamespace()) ? ts : ProtocolVariation.RM10WSA200408.getCodec().convertReceivedTerminateSequence(ts);
    MessageContentsList contents = new MessageContentsList();
    contents.add(tst);
    message.setContent(List.class, contents);
    RMContextUtils.setProtocolVariation(message, protocol);
    return message;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Identifier(org.apache.cxf.ws.rm.v200502.Identifier) Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) TerminateSequenceType(org.apache.cxf.ws.rm.v200502.TerminateSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 35 with MessageContentsList

use of org.apache.cxf.message.MessageContentsList in project cxf by apache.

the class ServantTest method createTestCloseSequenceMessage.

private static Message createTestCloseSequenceMessage(String sidstr) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);
    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    CloseSequenceType cs = new CloseSequenceType();
    org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier();
    sid.setValue(sidstr);
    cs.setIdentifier(sid);
    MessageContentsList contents = new MessageContentsList();
    contents.add(cs);
    message.setContent(List.class, contents);
    RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM11WSA200508);
    return message;
}
Also used : Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Exchange(org.apache.cxf.message.Exchange) Identifier(org.apache.cxf.ws.rm.v200502.Identifier) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Aggregations

MessageContentsList (org.apache.cxf.message.MessageContentsList)63 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)24 Exchange (org.apache.cxf.message.Exchange)22 Fault (org.apache.cxf.interceptor.Fault)19 Message (org.apache.cxf.message.Message)19 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)18 ArrayList (java.util.ArrayList)13 List (java.util.List)13 MessageImpl (org.apache.cxf.message.MessageImpl)11 Endpoint (org.apache.cxf.endpoint.Endpoint)10 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)10 Method (java.lang.reflect.Method)9 OperationInfo (org.apache.cxf.service.model.OperationInfo)9 Response (javax.ws.rs.core.Response)8 XMLStreamException (javax.xml.stream.XMLStreamException)8 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)8 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)8 MessageInfo (org.apache.cxf.service.model.MessageInfo)8 Test (org.junit.Test)8 Service (org.apache.cxf.service.Service)7