本文整理了Java中org.apache.cxf.message.Message
类的一些代码示例,展示了Message
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message
类的具体详情如下:
包路径:org.apache.cxf.message.Message
类名称:Message
[英]The base interface for all all message implementations. All message objects passed to interceptors use this interface.
[中]所有消息实现的基本接口。传递给拦截器的所有消息对象都使用此接口。
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
@Override
protected void updateMessageForSuspend() {
Message currentMessage = PhaseInterceptorChain.getCurrentMessage();
if (currentMessage.get(WriteListener.class) != null) {
// CXF Continuation WriteListener will likely need to be introduced
// for NIO supported with non-Servlet specific mechanisms
getOutputStream().setWriteListener(currentMessage.get(WriteListener.class));
currentMessage.getInterceptorChain().suspend();
} else {
inMessage.getExchange().getInMessage().getInterceptorChain().suspend();
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
private void handleAbort(Message message, W3CDOMStreamWriter writer) {
message.getInterceptorChain().abort();
if (!message.getExchange().isOneWay()) {
//server side inbound
Endpoint e = message.getExchange().getEndpoint();
Message responseMsg = new MessageImpl();
responseMsg.setExchange(message.getExchange());
responseMsg = e.getBinding().createMessage(responseMsg);
message.getExchange().setOutMessage(responseMsg);
XMLStreamReader reader = message.getContent(XMLStreamReader.class);
if (reader == null && writer != null) {
reader = StaxUtils.createXMLStreamReader(writer.getDocument());
}
InterceptorChain chain = OutgoingChainInterceptor
.getOutInterceptorChain(message.getExchange());
responseMsg.setInterceptorChain(chain);
responseMsg.put("LogicalHandlerInterceptor.INREADER", reader);
chain.doIntercept(responseMsg);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
/**
* Send an outbound message, assumed to contain all the name-value
* mappings of the corresponding input message (if any).
*
* @param message the message to be sent.
*/
public void prepare(Message message) throws IOException {
message.put(HTTP_RESPONSE, response);
OutputStream os = message.getContent(OutputStream.class);
if (os == null) {
message.setContent(OutputStream.class,
new WrappedOutputStream(message));
}
}
代码示例来源:origin: stackoverflow.com
final Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(senderAddress, senderDisplayName));
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress(m.getRecipient(), m.getRecipientDisplayName()));
msg.setSubject(m.getSubject());
// Unformatted text version
final MimeBodyPart textPart = new MimeBodyPart();
textPart.setContent(m.getText(), "text/plain");
// HTML version
final MimeBodyPart htmlPart = new MimeBodyPart();
htmlPart.setContent(m.getHtml(), "text/html");
// Create the Multipart. Add BodyParts to it.
final Multipart mp = new MimeMultipart("alternative");
mp.addBodyPart(textPart);
mp.addBodyPart(htmlPart);
// Set Multipart as the message's content
msg.setContent(mp);
LOGGER.log(Level.FINEST, "Sending email {0}", m);
Transport.send(msg);
代码示例来源:origin: stackoverflow.com
message.setFrom(new InternetAddress("from.mail.id@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("to.mail.id@gmail.com"));
message.setSubject("Testing Subject");
message.setText("PFA");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
protected void propagateConduit(Exchange exchange, Message in) {
if (exchange != null) {
Message out = exchange.getOutMessage();
if (out != null) {
in.put(Conduit.class, out.get(Conduit.class));
}
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class);
XMLStreamWriter origWriter = (XMLStreamWriter)message
.get(LogicalHandlerOutInterceptor.ORIGINAL_WRITER);
XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER");
SOAPMessage origMessage = null;
if (reader != null) {
origMessage = message.getContent(SOAPMessage.class);
message.setContent(XMLStreamReader.class, reader);
message.removeContent(SOAPMessage.class);
} else if (domWriter.getCurrentFragment() != null) {
DocumentFragment frag = domWriter.getCurrentFragment();
message.setContent(Source.class, source);
message.setContent(XMLStreamReader.class,
new W3CDOMStreamReader(domWriter.getCurrentFragment()));
} else if (domWriter.getDocument().getDocumentElement() != null) {
Source source = new DOMSource(domWriter.getDocument());
message.setContent(Source.class, source);
message.setContent(XMLStreamReader.class,
StaxUtils.createXMLStreamReader(domWriter.getDocument()));
message.getInterceptorChain().abort();
if (!message.getExchange().isOneWay()) {
Endpoint e = message.getExchange().getEndpoint();
Message responseMsg = new MessageImpl();
responseMsg.setExchange(message.getExchange());
responseMsg = e.getBinding().createMessage(responseMsg);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
W3CDOMStreamWriter domWriter = (W3CDOMStreamWriter)message.getContent(XMLStreamWriter.class);
XMLStreamWriter origWriter = (XMLStreamWriter)message
.get(LogicalHandlerFaultOutInterceptor.ORIGINAL_WRITER);
XMLStreamReader reader = (XMLStreamReader)message.get("LogicalHandlerInterceptor.INREADER");
SOAPMessage origMessage = null;
if (reader != null) {
origMessage = message.getContent(SOAPMessage.class);
message.setContent(XMLStreamReader.class, reader);
message.removeContent(SOAPMessage.class);
} else if (domWriter.getDocument().getDocumentElement() != null) {
Source source = new DOMSource(domWriter.getDocument());
message.setContent(Source.class, source);
message.setContent(Node.class, domWriter.getDocument());
message.setContent(XMLStreamReader.class,
StaxUtils.createXMLStreamReader(domWriter.getDocument()));
Exchange exchange = message.getExchange();
FaultMode mode = message.get(FaultMode.class);
Message faultMessage = exchange.getOutMessage();
if (null == faultMessage) {
faultMessage = new MessageImpl();
faultMessage.setExchange(message.getExchange());
faultMessage = exchange.getEndpoint().getBinding().createMessage(faultMessage);
faultMessage.setContent(Exception.class, ex);
if (null != mode) {
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
protected void handleResponseInternal() throws IOException {
Exchange exchange = outMessage.getExchange();
int responseCode = doProcessResponseCode();
inMessage.setExchange(exchange);
updateResponseHeaders(inMessage);
inMessage.put(Message.RESPONSE_CODE, responseCode);
if (MessageUtils.getContextualBoolean(outMessage, SET_HTTP_RESPONSE_MESSAGE, false)) {
inMessage.put(HTTP_RESPONSE_MESSAGE, getResponseMessage());
exchange.put("IN_CHAIN_COMPLETE", Boolean.TRUE);
outMessage.removeContent(OutputStream.class);
if (cachingForRetransmission && cachedStream != null) {
cachedStream.close();
String charset = HttpHeaderHelper.findCharset((String)inMessage.get(Message.CONTENT_TYPE));
String normalizedEncoding = HttpHeaderHelper.mapCharset(charset);
if (normalizedEncoding == null) {
String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",
LOG, charset).toString();
LOG.log(Level.WARNING, m);
throw new IOException(m);
inMessage.put(Message.ENCODING, normalizedEncoding);
if (in == null) {
in = getInputStream();
inMessage.setContent(InputStream.class, in);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
Exchange ex = message.getExchange();
BindingOperationInfo boi = ex.getBindingOperationInfo();
if (Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))
|| boi == null) {
return;
Method method = ex.get(Method.class);
MessageInfo wrappedMessageInfo = message.get(MessageInfo.class);
MessageInfo messageInfo;
if (wrappedMessageInfo == boi.getOperationInfo().getInput()) {
return;
message.put(MessageInfo.class, messageInfo);
message.put(BindingMessageInfo.class, bmi);
ex.put(BindingOperationInfo.class, boi2);
Service service = ServiceModelUtil.getService(message.getExchange());
DataBinding dataBinding = service.getDataBinding();
if (dataBinding instanceof WrapperCapableDatabinding) {
throw new Fault(e);
message.setContent(List.class, newParams);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
BindingOperationInfo bop = message.getExchange().getBindingOperationInfo();
if (bop != null && !bindingName.equals(bop.getBinding().getName())) {
return;
MessageContentsList list = (MessageContentsList)message.getContent(List.class);
DataSource ds = (DataSource)list.get(0);
String ct = ds.getContentType();
if (ct.toLowerCase().contains("multipart/related")) {
Message msg = new MessageImpl();
msg.setExchange(message.getExchange());
msg.put(Message.CONTENT_TYPE, ct);
try {
msg.setContent(InputStream.class, ds.getInputStream());
AttachmentDeserializer deser = new AttachmentDeserializer(msg);
deser.initializeAttachments();
} catch (IOException ex) {
throw new Fault(ex);
message.setAttachments(msg.getAttachments());
final InputStream in = msg.getContent(InputStream.class);
final String ct2 = (String)msg.get(Message.CONTENT_TYPE);
list.set(0, new DataSource() {
OutputStream out = message.getContent(OutputStream.class);
message.put(Message.CONTENT_TYPE, ct);
try {
InputStream in = ds.getInputStream();
message.setContent(OutputStream.class, out);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
Fault f = (Fault)message.getContent(Exception.class);
if (f == null) {
return;
SoapVersion soapVersion = (SoapVersion)message.get(SoapVersion.class.getName());
if (soapVersion != null && soapVersion.getVersion() != 1.1) {
if (f instanceof SoapFault) {
message.setContent(Exception.class, f);
Service service = message.getExchange().getService();
message.getExchange().getBus());
writer.setSchema(schema);
OperationInfo op = message.getExchange().getBindingOperationInfo().getOperationInfo();
QName faultName = getFaultName(fault, cause.getClass(), op);
MessagePartInfo part = getFaultMessagePart(faultName, op);
} catch (Exception nex) {
if (nex instanceof Fault) {
message.setContent(Exception.class, nex);
super.handleMessage(message);
} else {
FaultMode mode = message.get(FaultMode.class);
if (mode == FaultMode.CHECKED_APPLICATION_FAULT) {
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
Exchange ex = message.getExchange();
BindingOperationInfo bop = ex.getBindingOperationInfo();
MessageInfo messageInfo = message.get(MessageInfo.class);
if (messageInfo == null || bop == null || !bop.isUnwrapped()) {
return;
BindingOperationInfo newbop = bop.getWrappedOperation();
MessageInfo wrappedMsgInfo;
if (Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) {
wrappedMsgInfo = newbop.getInput().getMessageInfo();
} else {
wrappedMsgInfo = newbop.getOutput().getMessageInfo();
message.setContent(List.class, newObjs);
} catch (Fault f) {
throw f;
} catch (Exception e) {
throw new Fault(e);
ex.put(BindingOperationInfo.class, newbop);
if (messageInfo == bop.getOperationInfo().getInput()) {
message.put(MessageInfo.class, newbop.getOperationInfo().getInput());
message.put(BindingMessageInfo.class, newbop.getInput());
} else if (messageInfo == bop.getOperationInfo().getOutput()) {
message.put(MessageInfo.class, newbop.getOperationInfo().getOutput());
message.put(BindingMessageInfo.class, newbop.getOutput());
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
MessageContentsList outObjects = MessageContentsList.getContentsList(message);
Exchange exchange = message.getExchange();
OperationInfo op = exchange.getBindingOperationInfo() == null
? null
: exchange.getBindingOperationInfo().getOperationInfo();
if (!Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) {
List<MessagePartInfo> parts = op.getOutput().getMessageParts();
MessageContentsList inObjects = MessageContentsList.getContentsList(exchange.getInMessage());
if (inObjects != null) {
if (!(inObjects == outObjects)) {
throw new Fault(new org.apache.cxf.common.i18n.Message("CANNOT_SET_HOLDER_OBJECTS", LOG));
message.put(HolderInInterceptor.CLIENT_HOLDERS, holders);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
if (binding.getHandlerChain().isEmpty()) {
return;
}
HandlerChainInvoker invoker = getInvoker(message);
if (invoker.getLogicalHandlers().isEmpty()) {
return;
}
XMLStreamWriter origWriter = message.getContent(XMLStreamWriter.class);
Node nd = message.getContent(Node.class);
SOAPMessage m = message.getContent(SOAPMessage.class);
Document document = null;
if (m != null) {
document = m.getSOAPPart();
} else if (nd != null) {
document = nd.getOwnerDocument();
} else {
document = DOMUtils.newDocument();
message.setContent(Node.class, document);
}
W3CDOMStreamWriter writer = new W3CDOMStreamWriter(document.createDocumentFragment());
// Replace stax writer with DomStreamWriter
message.setContent(XMLStreamWriter.class, writer);
message.put(ORIGINAL_WRITER, origWriter);
message.getInterceptorChain().add(ending);
}
@Override
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
Service.Mode mode = msgContext.getWrappedMessage().getExchange().get(Service.Mode.class);
} else {
Message message = msgContext.getWrappedMessage();
source = message.getContent(Source.class);
if (source == null) {
SOAPMessage msg = message.getContent(SOAPMessage.class);
XMLStreamReader reader = null;
if (msg != null) {
DocumentFragment doc = DOMUtils.getEmptyDocument().createDocumentFragment();
W3CDOMStreamWriter writer = new W3CDOMStreamWriter(doc);
reader = message.getContent(XMLStreamReader.class);
throw new Fault(e);
message.setContent(XMLStreamReader.class, reader);
message.setContent(Source.class, source);
} else if (!(source instanceof DOMSource)) {
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
XMLStreamReader reader = message.getContent(XMLStreamReader.class);
throw new Fault(e);
message.setContent(XMLStreamReader.class, reader);
message.setContent(Source.class, source);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
MessageObserver observer = message.getExchange().get(MessageObserver.class);
if (!message.getExchange().isOneWay()
&& observer != null) {
Endpoint e = message.getExchange().getEndpoint();
Message responseMsg = new MessageImpl();
responseMsg.setExchange(message.getExchange());
responseMsg = e.getBinding().createMessage(responseMsg);
responseMsg.setContent(SOAPMessage.class, soapMessage);
XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(soapMessage);
responseMsg.setContent(XMLStreamReader.class, xmlReader);
responseMsg.put(InterceptorChain.STARTING_AT_INTERCEPTOR_ID,
SOAPHandlerInterceptor.class.getName());
observer.onMessage(responseMsg);
message.getInterceptorChain().abort();
Endpoint e = message.getExchange().getEndpoint();
if (!message.getExchange().isOneWay()) {
Message responseMsg = new MessageImpl();
responseMsg.setExchange(message.getExchange());
responseMsg = e.getBinding().createMessage(responseMsg);
message.getExchange().setOutMessage(responseMsg);
SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();
responseMsg.setContent(SOAPMessage.class, soapMessage);
responseMsg.setInterceptorChain(chain);
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
if (outMessage.getExchange() == null) {
return;
Message inMessage = outMessage.getExchange().getInMessage();
if (inMessage == null) {
return;
Object o = inMessage.get("cxf.io.cacheinput");
DelegatingInputStream in = inMessage.getContent(DelegatingInputStream.class);
if (PropertyUtils.isTrue(o)) {
Collection<Attachment> atts = inMessage.getAttachments();
if (atts != null) {
for (Attachment a : atts) {
((AttachmentDataSource)a.getDataHandler().getDataSource()).cache(inMessage);
} catch (IOException e) {
throw new Fault(e);
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
@Override
public void handleFault(Message message) {
Exception ex = message.getContent(Exception.class);
if (ex instanceof AuthenticationException) {
HttpServletResponse resp = (HttpServletResponse)message.getExchange()
.getInMessage().get(AbstractHTTPDestination.HTTP_RESPONSE);
resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
resp.setHeader("WWW-Authenticate", authenticationType + " realm=\"" + realm + "\"");
resp.setContentType("text/plain");
try {
resp.getOutputStream().write(ex.getMessage().getBytes());
resp.getOutputStream().flush();
message.getInterceptorChain().setFaultObserver(null); //avoid return soap fault
message.getInterceptorChain().abort();
} catch (IOException e) {
// TODO
}
}
}
代码示例来源:origin: apache/cxf
protected <T> DataReader<T> getDataReader(Message message, Class<T> input) {
Service service = ServiceModelUtil.getService(message.getExchange());
DataReader<T> dataReader = service.getDataBinding().createReader(input);
if (dataReader == null) {
throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAREADER",
BUNDLE, service.getName()));
}
dataReader.setAttachments(message.getAttachments());
dataReader.setProperty(DataReader.ENDPOINT, message.getExchange().getEndpoint());
dataReader.setProperty(Message.class.getName(), message);
setDataReaderValidation(service, message, dataReader);
return dataReader;
}
内容来源于网络,如有侵权,请联系作者删除!