本文整理了Java中org.apache.cxf.message.Message.setContent()
方法的一些代码示例,展示了Message.setContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setContent()
方法的具体详情如下:
包路径:org.apache.cxf.message.Message
类名称:Message
方法名:setContent
[英]Provide the encapsulated content as a particular type (a result type if message is outbound, a source type if message is inbound)
[中]以特定类型提供封装的内容(如果消息是出站的,则为结果类型;如果消息是入站的,则为源类型)
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
@Override
public void handleFault(Message message) {
super.handleFault(message);
XMLStreamWriter os = (XMLStreamWriter)message.get(ORIGINAL_WRITER);
if (os != null) {
message.setContent(XMLStreamWriter.class, os);
}
}
代码示例来源: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: org.apache.cxf/cxf-rt-frontend-jaxws
public void setMessage(SOAPMessage message) {
if (getWrappedMessage().getContent(Object.class) instanceof SOAPMessage) {
getWrappedMessage().setContent(Object.class, message);
} else {
getWrappedMessage().setContent(SOAPMessage.class, message);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public Source getPayload() {
Source source = null;
Service.Mode mode = msgContext.getWrappedMessage().getExchange().get(Service.Mode.class);
SOAPMessage msg = message.getContent(SOAPMessage.class);
XMLStreamReader reader = null;
if (msg != null) {
reader = StaxUtils.createXMLStreamReader(source);
} catch (SOAPException e) {
throw new Fault(e);
DocumentFragment doc = DOMUtils.getEmptyDocument().createDocumentFragment();
W3CDOMStreamWriter writer = new W3CDOMStreamWriter(doc);
reader = message.getContent(XMLStreamReader.class);
reader = StaxUtils.createXMLStreamReader(DOMUtils.getFirstElement(doc));
} catch (XMLStreamException e) {
throw new Fault(e);
message.setContent(XMLStreamReader.class, reader);
message.setContent(Source.class, source);
} else if (!(source instanceof DOMSource)) {
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
message.setContent(XMLStreamReader.class, reader);
message.setContent(Source.class, source);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
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) {
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()));
if (observer != null) {
responseMsg.setContent(XMLStreamReader.class, message
.getContent(XMLStreamReader.class));
message.setContent(SOAPMessage.class, origMessage);
message.setContent(XMLStreamWriter.class, origWriter);
} catch (XMLStreamException e) {
throw new Fault(e);
代码示例来源: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;
BindingMessageInfo bmi;
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
} else if (DataSource.class.isAssignableFrom(type)) {
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);
final InputStream in = msg.getContent(InputStream.class);
final String ct2 = (String)msg.get(Message.CONTENT_TYPE);
list.set(0, new DataSource() {
out.close();
} catch (IOException e) {
throw new Fault(e);
message.setContent(OutputStream.class, out);
XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out);
message.setContent(XMLStreamWriter.class, writer);
代码示例来源: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);
Document doc = DOMUtils.newDocument();
message.setContent(Node.class, doc);
W3CDOMStreamWriter writer = new W3CDOMStreamWriter(doc);
// set up the namespace context
try {
writer.setNamespaceContext(origWriter.getNamespaceContext());
} catch (XMLStreamException ex) {
// don't set the namespaceContext
}
// Replace stax writer with DomStreamWriter
message.setContent(XMLStreamWriter.class, writer);
message.put(ORIGINAL_WRITER, origWriter);
message.getInterceptorChain().add(ending);
}
代码示例来源:origin: apache/cxf
public void handleMessage(Message message) throws Fault {
OutputStream out = message.getContent(OutputStream.class);
if (out != null) {
CountingOutputStream newOut = new CountingOutputStream(out);
message.setContent(OutputStream.class, newOut);
message.getExchange().put(CountingOutputStream.class, newOut);
}
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-jbi
/**
* 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 {
// setup the message to be send back
DeliveryChannel dc = channel;
message.put(MessageExchange.class, inMessage.get(MessageExchange.class));
message.setContent(OutputStream.class,
new JBIDestinationOutputStream(inMessage, message, dc));
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
private void doFromSoapMessage(Message message, Object sm) {
SOAPMessage m = (SOAPMessage)sm;
MessageContentsList list = (MessageContentsList)message.getContent(List.class);
if (list == null) {
list = new MessageContentsList();
message.setContent(List.class, list);
}
Object o = m;
if (StreamSource.class.isAssignableFrom(type)) {
try {
try (CachedOutputStream out = new CachedOutputStream()) {
XMLStreamWriter xsw = StaxUtils.createXMLStreamWriter(out);
StaxUtils.copy(new DOMSource(m.getSOAPPart()), xsw);
xsw.close();
o = new StreamSource(out.getInputStream());
}
} catch (Exception e) {
throw new Fault(e);
}
} else if (SAXSource.class.isAssignableFrom(type)) {
o = new StaxSource(new W3CDOMStreamReader(m.getSOAPPart()));
} else if (Source.class.isAssignableFrom(type)) {
o = new DOMSource(m.getSOAPPart());
}
list.set(0, o);
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
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);
SOAPMessage soapMessage = ((SOAPMessageContext)context).getMessage();
responseMsg.setContent(SOAPMessage.class, soapMessage);
代码示例来源:origin: org.ow2.petals/petals-se-activiti
@Override
public void prepare(final Message message) throws IOException {
try {
final NormalizedMessageOutputStream out = new NormalizedMessageOutputStream(this.sender,
message.getExchange(), this.asyncCallback, flowAttributes.get());
message.setContent(OutputStream.class, out);
} catch (final MessagingException e) {
throw new IOException(e);
} catch (final PEtALSCDKException e) {
throw new IOException(e);
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
inMessage.getExchange().put(Bus.class, bus);
inMessage.put(Message.DECOUPLED_CHANNEL_MESSAGE, Boolean.TRUE);
inMessage.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_OK);
InputStream in = inMessage.getContent(InputStream.class);
if (in != null) {
CachedOutputStream cos = new CachedOutputStream();
IOUtils.copy(in, cos);
inMessage.setContent(InputStream.class, cos.getInputStream());
代码示例来源:origin: Talend/tesb-rt-se
public void performTransformation(Message message) {
Reader transformedReader = null;
try {
transformedReader = XSLTUtils.transform(xsltTemplate, getReader());
IOUtils.copyAndCloseInput(transformedReader, origWriter, IOUtils.DEFAULT_BUFFER_SIZE);
message.setContent(Writer.class, origWriter);
} catch (IOException e) {
throw new Fault("READER_COPY", LOG, e, e.getMessage());
}
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
resp);
final Exchange exchange = inMessage.getExchange();
DelegatingInputStream in = new DelegatingInputStream(req.getInputStream()) {
public void cacheInput() {
inMessage.setContent(DelegatingInputStream.class, in);
inMessage.setContent(InputStream.class, in);
inMessage.put(HTTP_REQUEST, req);
inMessage.put(HTTP_RESPONSE, resp);
inMessage.put(HTTP_CONTEXT, context);
inMessage.put(HTTP_CONFIG, config);
inMessage.put(HTTP_CONTEXT_MATCH_STRATEGY, contextMatchStrategy);
代码示例来源:origin: apache/cxf
public void handleMessage(Message message) throws Fault {
if (message.getExchange().get(Throwable.class) != null) {
return;
}
try {
Document doc = getDomDocument(message);
if (doc == null) {
return;
}
Document finalDoc = processDocument(message, doc);
message.setContent(List.class,
new MessageContentsList(new DOMSource(finalDoc)));
} catch (Exception ex) {
StringWriter sw = new StringWriter();
ex.printStackTrace(new PrintWriter(sw));
LOG.warning(sw.toString());
throw new Fault(new RuntimeException(ex.getMessage() + ", stacktrace: " + sw.toString()));
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
Service.Mode mode = (Service.Mode)msgContext.getWrappedMessage()
.getContextualProperty(Service.Mode.class.getName());
SOAPMessage m = message.getContent(SOAPMessage.class);
if (m != null && !MessageUtils.isOutbound(message)) {
try {
message.setContent(XMLStreamReader.class, r);
} catch (Exception e) {
throw new Fault(e);
s = new DOMSource(msg.getSOAPPart());
} catch (Exception e) {
throw new Fault(e);
} else if (message instanceof XMLMessage && message.getContent(DataSource.class) != null) {
throw new Fault(
new org.apache.cxf.common.i18n.Message(
"GETPAYLOAD_OF_DATASOURCE_NOT_VALID_XMLHTTPBINDING",
msgContext.getWrappedMessage().setContent(XMLStreamReader.class, reader);
msgContext.getWrappedMessage().setContent(Source.class, s);
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws
public void handleMessage(Message message) throws Fault {
MessageContentsList inObjects = MessageContentsList.getContentsList(message);
Exchange exchange = message.getExchange();
BindingOperationInfo bop = exchange.getBindingOperationInfo();
if (bop == null) {
boolean client = Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
if (client) {
List<Holder<?>> outHolders = CastUtils.cast((List<?>)message.getExchange()
.getOutMessage().get(CLIENT_HOLDERS));
for (MessagePartInfo part : parts) {
if (part.getIndex() != 0 && part.getTypeClass() != null) {
message.setContent(List.class, inObjects);
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
public void run() {
try {
handleResponseInternal();
} catch (Throwable e) {
((PhaseInterceptorChain)outMessage.getInterceptorChain()).abort();
outMessage.setContent(Exception.class, e);
((PhaseInterceptorChain)outMessage.getInterceptorChain()).unwind(outMessage);
MessageObserver mo = outMessage.getInterceptorChain().getFaultObserver();
if (mo == null) {
mo = outMessage.getExchange().get(MessageObserver.class);
}
mo.onMessage(outMessage);
}
}
};
内容来源于网络,如有侵权,请联系作者删除!