本文整理汇总了Java中org.apache.axis2.util.MessageProcessorSelector类的典型用法代码示例。如果您正苦于以下问题:Java MessageProcessorSelector类的具体用法?Java MessageProcessorSelector怎么用?Java MessageProcessorSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageProcessorSelector类属于org.apache.axis2.util包,在下文中一共展示了MessageProcessorSelector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMessageFormatter
import org.apache.axis2.util.MessageProcessorSelector; //导入依赖的package包/类
/**
* Get the correct formatter for message
*
* @param msgContext The message context that is generated for processing the file
*/
private MessageFormatter getMessageFormatter(org.apache.axis2.context.MessageContext msgContext) {
OMElement firstChild = msgContext.getEnvelope().getBody().getFirstElement();
if (firstChild != null) {
if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) {
return new BinaryFormatter();
} else if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(firstChild.getQName())) {
return new PlainTextFormatter();
}
}
try {
return MessageProcessorSelector.getMessageFormatter(msgContext);
} catch (Exception e) {
throw new BaseTransportException("Unable to get the message formatter to use");
}
}
示例2: getMessageFormatter
import org.apache.axis2.util.MessageProcessorSelector; //导入依赖的package包/类
/**
* Get the MessageFormatter for the given message.
* @param msgContext the axis message context
* @return the MessageFormatter to be used
*/
public static MessageFormatter getMessageFormatter(MessageContext msgContext) {
// check the first element of the SOAP body, do we have content wrapped using the
// default wrapper elements for binary (BaseConstants.DEFAULT_BINARY_WRAPPER) or
// text (BaseConstants.DEFAULT_TEXT_WRAPPER) ? If so, select the appropriate
// message formatter directly ...
OMElement firstChild = msgContext.getEnvelope().getBody().getFirstElement();
if (firstChild != null) {
if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) {
return new BinaryFormatter();
} else if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(firstChild.getQName())) {
return new PlainTextFormatter();
}
}
// ... otherwise, let Axis choose the right message formatter:
try {
return MessageProcessorSelector.getMessageFormatter(msgContext);
} catch (AxisFault axisFault) {
throw new BaseTransportException("Unable to get the message formatter to use");
}
}
示例3: sendMessage
import org.apache.axis2.util.MessageProcessorSelector; //导入依赖的package包/类
@Override
public void sendMessage(MessageContext msgContext, String targetEPR,
OutTransportInfo outTransportInfo) throws AxisFault {
UDPOutTransportInfo udpOutInfo;
if ((targetEPR == null) && (outTransportInfo != null)) {
// this can happen only at the server side and send the message using back chanel
udpOutInfo = (UDPOutTransportInfo) outTransportInfo;
} else {
udpOutInfo = new UDPOutTransportInfo(targetEPR);
}
MessageFormatter messageFormatter = MessageProcessorSelector.getMessageFormatter(msgContext);
OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext);
format.setContentType(udpOutInfo.getContentType());
byte[] payload = messageFormatter.getBytes(msgContext, format);
try {
DatagramSocket socket = new DatagramSocket();
if (log.isDebugEnabled()) {
log.debug("Sending " + payload.length + " bytes to " + udpOutInfo.getAddress());
}
try {
socket.send(new DatagramPacket(payload, payload.length, udpOutInfo.getAddress()));
if (!msgContext.getOptions().isUseSeparateListener() &&
!msgContext.isServerSide()){
waitForReply(msgContext, socket, udpOutInfo.getContentType());
}
}
finally {
socket.close();
}
}
catch (IOException ex) {
throw new AxisFault("Unable to send packet", ex);
}
}
示例4: getAttachmentsBuilder
import org.apache.axis2.util.MessageProcessorSelector; //导入依赖的package包/类
public static StAXBuilder getAttachmentsBuilder(MessageContext msgContext,
InputStream inStream, String contentTypeString,
boolean isSOAP)
throws OMException, XMLStreamException, FactoryConfigurationError {
StAXBuilder builder = null;
XMLStreamReader streamReader;
Attachments attachments = createAttachmentsMap(msgContext, inStream, contentTypeString);
String charSetEncoding = getCharSetEncoding(attachments.getSOAPPartContentType());
if ((charSetEncoding == null)
|| "null".equalsIgnoreCase(charSetEncoding)) {
charSetEncoding = MessageContext.UTF_8;
}
msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
charSetEncoding);
try {
PushbackInputStream pis = getPushbackInputStream(attachments.getSOAPPartInputStream());
String actualCharSetEncoding = getCharSetEncoding(pis, charSetEncoding);
streamReader = StAXUtils.createXMLStreamReader(pis, actualCharSetEncoding);
} catch (IOException e) {
throw new XMLStreamException(e);
}
// Put a reference to Attachments Map in to the message context For
// backword compatibility with Axis2 1.0
msgContext.setProperty(MTOMConstants.ATTACHMENTS, attachments);
// Setting the Attachments map to new SwA API
msgContext.setAttachmentMap(attachments);
String soapEnvelopeNamespaceURI = getEnvelopeNamespace(contentTypeString);
return MessageProcessorSelector.getAttachmentBuilder(msgContext, attachments, streamReader, soapEnvelopeNamespaceURI, isSOAP);
}
示例5: populateCommonProperties
import org.apache.axis2.util.MessageProcessorSelector; //导入依赖的package包/类
/**
* Method used to copy all the common properties
*
* @param msgContext - The messageContext of the request message
* @param url - The target URL
* @param httpMethod - The http method used to send the request
* @param httpClient - The httpclient used to send the request
* @param soapActionString - The soap action atring of the request message
* @return MessageFormatter - The messageFormatter for the relavent request message
* @throws AxisFault - Thrown in case an exception occurs
*/
protected MessageFormatter populateCommonProperties(MessageContext msgContext, URL url,
HttpMethodBase httpMethod,
HttpClient httpClient,
String soapActionString)
throws AxisFault {
if (isAuthenticationEnabled(msgContext)) {
httpMethod.setDoAuthentication(true);
}
MessageFormatter messageFormatter = MessageProcessorSelector
.getMessageFormatter(msgContext);
url = messageFormatter.getTargetAddress(msgContext, format, url);
httpMethod.setPath(url.getPath());
httpMethod.setQueryString(url.getQuery());
// If adding the Content-Type header from the message formatter needs to be skipped
if (Boolean.parseBoolean((String)msgContext.getProperty(HTTPConstants.NO_DEFAULT_CONTENT_TYPE))) {
// Check whether message context already has the Content-Type header,
// if so use that as the Content-Type header
Object transportHeadersObj = msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
if (transportHeadersObj != null && transportHeadersObj instanceof Map) {
Map transportHeaders = (Map) transportHeadersObj;
Object headerContentType = transportHeaders.get(HTTPConstants.HEADER_CONTENT_TYPE);
if (headerContentType != null) {
httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE, headerContentType.toString());
}
}
// If NO_DEFAULT_CONTENT_TYPE is set to true and the Content-Type header is not present
// in the message context, backend will receive a request without a Content-Type header
} else {
httpMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
messageFormatter.getContentType(msgContext, format, soapActionString));
}
httpMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
if (msgContext.getOptions() != null && msgContext.getOptions().isManageSession()) {
// setting the cookie in the out path
Object cookieString = msgContext.getProperty(HTTPConstants.COOKIE_STRING);
if (cookieString != null) {
StringBuffer buffer = new StringBuffer();
buffer.append(cookieString);
httpMethod.setRequestHeader(HTTPConstants.HEADER_COOKIE, buffer.toString());
}
}
if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
httpClient.getParams().setVersion(HttpVersion.HTTP_1_0);
}
return messageFormatter;
}