本文整理了Java中org.apache.cxf.message.Message.getAttachments()
方法的一些代码示例,展示了Message.getAttachments()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getAttachments()
方法的具体详情如下:
包路径:org.apache.cxf.message.Message
类名称:Message
方法名:getAttachments
[英]Retrieve any binary attachments associated with the message.
[中]检索与邮件关联的任何二进制附件。
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
MultiPartDataSource(Message message, DataSource root) {
atts = message.getAttachments().iterator();
String s = (String)message.get(Message.CONTENT_TYPE);
boundary = findBoundary(s);
start = findStart(s);
if (!s.contains(boundary)) {
s += "; boundary=\"" + boundary + "\"";
}
contentType = s;
rootPart = root;
try {
writer = new OutputStreamWriter(bout, "ASCII");
writer.append("Content-Type: ").append(contentType).append("\r\n\r\n");
writer.flush();
current = bout.createInputStream();
} catch (Exception e) {
//nothing
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
private void doDataSource(final Message message) {
MessageContentsList list = (MessageContentsList)message.getContent(List.class);
//reconstitute all the parts into a Mime data source
if (message.getAttachments() != null && !message.getAttachments().isEmpty()
&& list != null
&& !list.isEmpty() && list.get(0) instanceof DataSource) {
list.set(0, new MultiPartDataSource(message, (DataSource)list.get(0)));
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
throw new Fault(ex);
message.setAttachments(msg.getAttachments());
final InputStream in = msg.getContent(InputStream.class);
final String ct2 = (String)msg.get(Message.CONTENT_TYPE);
代码示例来源:origin: org.apache.servicemix/servicemix-cxf-bc
private void loadAttachments(Message message) {
//get chance to cache the attachments
if (message.getAttachments() != null) {
LazyAttachmentCollection attachments = (LazyAttachmentCollection) message.getAttachments();
attachments.size();
}
}
代码示例来源:origin: org.apache.servicemix/servicemix-cxf-bc
public void handleMessage(Message message) throws Fault {
if (message.getAttachments() != null && message.getAttachments().size() > 0) {
message.put(org.apache.cxf.message.Message.MTOM_ENABLED, mtomEnabled);
message.put("write.attachments", mtomEnabled);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
DelegatingInputStream in = inMessage.getContent(DelegatingInputStream.class);
if (PropertyUtils.isTrue(o)) {
Collection<Attachment> atts = inMessage.getAttachments();
if (atts != null) {
for (Attachment a : atts) {
代码示例来源:origin: org.apache.servicemix/servicemix-cxf-bc
private void toNMSAttachments(NormalizedMessage normalizedMessage,
Message soapMessage) throws MessagingException {
if (soapMessage.getAttachments() != null) {
for (Attachment att : soapMessage.getAttachments()) {
normalizedMessage.addAttachment(att.getId(), att
.getDataHandler());
}
}
}
代码示例来源:origin: org.apache.servicemix/servicemix-cxf-bc
/**
* Convert SoapMessage attachments to NormalizedMessage attachments
*/
private void toNMSAttachments(NormalizedMessage normalizedMessage,
Message soapMessage) throws MessagingException {
if (soapMessage.getAttachments() != null) {
for (Attachment att : soapMessage.getAttachments()) {
normalizedMessage.addAttachment(att.getId(), att
.getDataHandler());
}
}
}
代码示例来源:origin: apache/cxf
private void assertIsNotTextMessageAndMtom(final Message outMessage) {
boolean isTextPayload = JMSConstants.TEXT_MESSAGE_TYPE.equals(jmsConfig.getMessageType());
if (isTextPayload && MessageUtils.getContextualBoolean(outMessage, org.apache.cxf.message.Message.MTOM_ENABLED)
&& outMessage.getAttachments() != null && outMessage.getAttachments().size() > 0) {
org.apache.cxf.common.i18n.Message msg =
new org.apache.cxf.common.i18n.Message("INVALID_MESSAGE_TYPE", LOG);
throw new ConfigurationException(msg);
}
}
代码示例来源:origin: org.mule.services/mule-service-soap
@Override
public void handleMessage(Message message) throws Fault {
final ImmutableMap.Builder<String, SoapAttachment> result = ImmutableMap.builder();
Collection<Attachment> attachments = message.getAttachments();
if (attachments != null && !attachments.isEmpty()) {
attachments.forEach(a -> result.put(getName(a), getSoapAttachment(a)));
}
message.getExchange().put(MULE_ATTACHMENTS_KEY, result.build());
}
代码示例来源:origin: apache/cxf
private void doDataSource(final Message message) {
MessageContentsList list = (MessageContentsList)message.getContent(List.class);
//reconstitute all the parts into a Mime data source
if (message.getAttachments() != null && !message.getAttachments().isEmpty()
&& list != null
&& !list.isEmpty() && list.get(0) instanceof DataSource) {
list.set(0, new MultiPartDataSource(message, (DataSource)list.get(0)));
}
}
代码示例来源:origin: apache/cxf
public void handleMessage(Message message) throws Fault {
Assert.assertNotNull(message.getAttachments());
Assert.assertEquals(1, message.getAttachments().size());
}
}
代码示例来源:origin: org.mule.modules/mule-module-cxf
public void handleMessage(Message message) throws Fault
{
MuleEvent event = (MuleEvent) message.getExchange().get(CxfConstants.MULE_EVENT);
MuleMessage muleMsg = event.getMessage();
Collection<Attachment> atts = message.getAttachments();
if (atts != null && !atts.isEmpty())
{
muleMsg.setInvocationProperty(CxfConstants.ATTACHMENTS, atts);
muleMsg.setOutboundProperty(HttpConstants.HEADER_CONTENT_TYPE, muleMsg.getInboundProperty(HttpConstants.HEADER_CONTENT_TYPE));
}
}
代码示例来源:origin: apache/cxf
public void handleMessage(Message message) throws Fault {
Assert.assertEquals("check attachment count", 1, message.getAttachments().size());
Attachment att = message.getAttachments().iterator().next();
Assert.assertNotNull("Attachment is null", att);
Assert.assertNotNull("Attachment content-type is null", att.getDataHandler().getDataSource()
.getContentType());
}
代码示例来源: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;
}
代码示例来源:origin: apache/cxf
protected DataWriter<XMLStreamWriter> getDataWriter(Message message) {
Service service = ServiceModelUtil.getService(message.getExchange());
DataWriter<XMLStreamWriter> dataWriter = service.getDataBinding().createWriter(XMLStreamWriter.class);
if (dataWriter == null) {
throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAWRITER", BUNDLE, service
.getName()));
}
dataWriter.setAttachments(message.getAttachments());
setDataWriterValidation(service, message, dataWriter);
return dataWriter;
}
private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) {
代码示例来源:origin: org.apache.cxf/cxf-core
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;
}
代码示例来源:origin: org.apache.cxf/cxf-api
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;
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
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;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-bindings-soap
protected DataWriter<XMLStreamWriter> getDataWriter(Message message) {
Service service = ServiceModelUtil.getService(message.getExchange());
DataWriter<XMLStreamWriter> dataWriter = service.getDataBinding().createWriter(XMLStreamWriter.class);
if (dataWriter == null) {
throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAWRITER", BUNDLE, service
.getName()));
}
dataWriter.setAttachments(message.getAttachments());
setDataWriterValidation(service, message, dataWriter);
return dataWriter;
}
private void setDataWriterValidation(Service service, Message message, DataWriter<?> writer) {
内容来源于网络,如有侵权,请联系作者删除!