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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations