本文整理汇总了Java中org.apache.axiom.om.OMOutputFormat类的典型用法代码示例。如果您正苦于以下问题:Java OMOutputFormat类的具体用法?Java OMOutputFormat怎么用?Java OMOutputFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OMOutputFormat类属于org.apache.axiom.om包,在下文中一共展示了OMOutputFormat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getOMOutputFormat
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
/**
* Get the OMOutput format for the given message
* @param msgContext the axis message context
* @return the OMOutput format to be used
*/
public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) {
OMOutputFormat format = new OMOutputFormat();
msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext));
msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext));
msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext));
format.setSOAP11(msgContext.isSOAP11());
format.setDoOptimize(msgContext.isDoingMTOM());
format.setDoingSWA(msgContext.isDoingSwA());
format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext));
Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY);
if (mimeBoundaryProperty != null) {
format.setMimeBoundary((String) mimeBoundaryProperty);
}
return format;
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:23,代码来源:BaseUtils.java
示例2: testWithCustomEncodingDeclaration
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public void testWithCustomEncodingDeclaration() throws Exception {
ApplicationXMLFormatter xmlFormatter = new ApplicationXMLFormatter();
MessageContext messageContext = new MessageContext();
messageContext.setProperty("WRITE_XML_DECLARATION", "true");
messageContext.setProperty("XML_DECLARATION_ENCODING", StandardCharsets.ISO_8859_1.toString());
createPayload(messageContext);
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(StandardCharsets.UTF_8.toString());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xmlFormatter.writeTo(messageContext, format, baos, true);
String output = new String(baos.toByteArray());
assertEquals("Compare payload with custom encoding XML declaration",
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?><hello>world</hello>", output);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:18,代码来源:XMLDeclarationTest.java
示例3: testWithDeclaration
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public void testWithDeclaration() throws Exception {
ApplicationXMLFormatter xmlFormatter = new ApplicationXMLFormatter();
MessageContext messageContext = new MessageContext();
messageContext.setProperty("WRITE_XML_DECLARATION", "true");
createPayload(messageContext);
OMOutputFormat format = new OMOutputFormat();
format.setCharSetEncoding(StandardCharsets.UTF_8.toString());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
xmlFormatter.writeTo(messageContext, format, baos, true);
String output = new String(baos.toByteArray());
assertEquals("Compare payload with default XML declaration",
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?><hello>world</hello>", output);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:XMLDeclarationTest.java
示例4: writeXMLDeclaration
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
private void writeXMLDeclaration(MessageContext messageContext, OutputStream outputStream, OMOutputFormat format) {
String xmlDeclaration;
String writeXmlDeclaration = (String) messageContext.getProperty(WRITE_XML_DECLARATION);
if (writeXmlDeclaration != null && "true".equalsIgnoreCase(writeXmlDeclaration)) {
String xmlDeclarationEncoding = (String) messageContext.getProperty(XML_DECLARATION_ENCODING);
if (xmlDeclarationEncoding == null) {
xmlDeclarationEncoding = (format.getCharSetEncoding() != null) ?
format.getCharSetEncoding() :
Charset.defaultCharset().toString();
}
String xmlDeclarationStandalone = (String) messageContext.getProperty(XML_DECLARATION_STANDALONE);
if (xmlDeclarationStandalone != null) {
xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" " + "standalone=\""
+ xmlDeclarationStandalone + "\" ?>";
} else {
xmlDeclaration = "<?xml version=\"1.0\" encoding=\"" + xmlDeclarationEncoding + "\" ?>";
}
try {
outputStream.write(xmlDeclaration.getBytes());
} catch (IOException e) {
log.error("Error while writing the XML declaration ", e);
}
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:ApplicationXMLFormatter.java
示例5: encode
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public byte[] encode(ClientOptions options, XMLMessage message) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OMOutputFormat outputFormat = new OMOutputFormat();
outputFormat.setCharSetEncoding(options.getCharset());
outputFormat.setIgnoreXMLDeclaration(true);
if (message.getType() == XMLMessage.Type.SWA) {
outputFormat.setMimeBoundary(options.getMimeBoundary());
outputFormat.setRootContentId(options.getRootContentId());
StringWriter writer = new StringWriter();
message.getMessageElement().serializeAndConsume(writer);
MIMEOutputUtils.writeSOAPWithAttachmentsMessage(writer, baos, message.getAttachments(), outputFormat);
} else {
message.getMessageElement().serializeAndConsume(baos, outputFormat);
}
return baos.toByteArray();
}
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:17,代码来源:MessageEncoder.java
示例6: getBytes
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
/**
* Retrieves the raw bytes from the SOAP envelop.
*
* @see org.apache.axis2.transport.MessageFormatter#getBytes(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat)
*/
public byte[] getBytes(MessageContext messageContext, OMOutputFormat format)
throws AxisFault {
//For POX drop the SOAP envelope and use the message body
OMElement element = messageContext.getEnvelope().getBody().getFirstElement();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
try {
//Creates StAX document serializer which actually implements the XMLStreamWriter
XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream);
//Since we drop the SOAP envelop we have to manually write the start document and the end document events
streamWriter.writeStartDocument();
element.serializeAndConsume(streamWriter);
streamWriter.writeEndDocument();
return outStream.toByteArray();
} catch (XMLStreamException xmlse) {
logger.error(xmlse.getMessage());
throw new AxisFault(xmlse.getMessage(), xmlse);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:FastInfosetPOXMessageFormatter.java
示例7: getBytes
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
/**
* Retrieves the raw bytes from the SOAP envelop.
*
* @see org.apache.axis2.transport.MessageFormatter#getBytes(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat)
*/
public byte[] getBytes(MessageContext messageContext, OMOutputFormat format)
throws AxisFault {
OMElement element = messageContext.getEnvelope();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
try {
//Creates StAX document serializer which actually implements the XMLStreamWriter
XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream);
element.serializeAndConsume(streamWriter);
//TODO Looks like the SOAP envelop doesn't have an end document tag. Find out why?
streamWriter.writeEndDocument();
return outStream.toByteArray();
} catch (XMLStreamException xmlse) {
logger.error(xmlse.getMessage());
throw new AxisFault(xmlse.getMessage(), xmlse);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:FastInfosetMessageFormatter.java
示例8: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
/**
* Returns the content type
*
* @see org.apache.axis2.transport.MessageFormatter#getContentType(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.lang.String)
*/
public String getContentType(MessageContext messageContext,
OMOutputFormat format, String soapAction) {
String contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
String encoding = format.getCharSetEncoding();
//If the Content Type is not available with the property "Content Type" retrieve it from the property "Message Type"
if (contentType == null) {
contentType = (String) messageContext.getProperty(Constants.Configuration.MESSAGE_TYPE);
}
if (encoding != null) {
contentType += "; charset=" + encoding;
}
return contentType;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:FastInfosetMessageFormatter.java
示例9: getTargetAddress
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
/**
* Returns the target address to send the response
* FIXME This is very HTTP specific. What about other transport?
*
* @see org.apache.axis2.transport.MessageFormatter#getTargetAddress(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.net.URL)
*/
public URL getTargetAddress(MessageContext messageContext,
OMOutputFormat format, URL targetURL) throws AxisFault {
String httpMethod =
(String) messageContext.getProperty(Constants.Configuration.HTTP_METHOD);
URL targetAddress = targetURL; //Let's initialize to this
//if the http method is GET, parameters are attached to the target URL
if ((httpMethod != null)
&& Constants.Configuration.HTTP_METHOD_GET.equalsIgnoreCase(httpMethod)) {
String param = getParam(messageContext);
if (param.length() > 0) {
String returnURLFile = targetURL.getFile() + "?" + param;
try {
targetAddress =
new URL(targetURL.getProtocol(), targetURL.getHost(), targetURL.getPort(), returnURLFile);
} catch (MalformedURLException murle) {
logger.error(murle.getMessage());
throw new AxisFault(murle.getMessage(), murle);
}
}
}
return targetAddress;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:FastInfosetMessageFormatter.java
示例10: writeTo
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
/**
* Write the SOAP envelop to the given OutputStream.
*
* @see org.apache.axis2.transport.MessageFormatter#writeTo(org.apache.axis2.context.MessageContext, org.apache.axiom.om.OMOutputFormat, java.io.OutputStream, boolean)
*/
public void writeTo(MessageContext messageContext, OMOutputFormat format,
OutputStream outputStream, boolean preserve) throws AxisFault {
OMElement element = messageContext.getEnvelope();
try {
//Create the StAX document serializer
XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream);
if (preserve) {
element.serialize(streamWriter);
} else {
element.serializeAndConsume(streamWriter);
}
// TODO Looks like the SOAP envelop doesn't have a end document tag. Find out why?
streamWriter.writeEndDocument();
} catch (XMLStreamException xmlse) {
logger.error(xmlse.getMessage());
throw new AxisFault(xmlse.getMessage(), xmlse);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:FastInfosetMessageFormatter.java
示例11: formatSOAPAction
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public String formatSOAPAction(MessageContext msgCtxt, OMOutputFormat format,
String soapActionString) {
// if SOAP 1.2 we attach the soap action to the content-type
// No need to set it as a header.
if (msgCtxt.isSOAP11()) {
if ("".equals(soapActionString)) {
return "\"\"";
} else {
if (soapActionString != null
&& !soapActionString.startsWith("\"")) {
// SOAPAction string must be a quoted string
soapActionString = "\"" + soapActionString + "\"";
}
return soapActionString;
}
}
return null;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:SOAPMessageFormatter.java
示例12: getBytes
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
/**
* @return a byte array of the message formatted according to the given
* message format.
*/
public byte[] getBytes(MessageContext messageContext, OMOutputFormat format) throws AxisFault {
OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
Part[] parts = createMultipatFormDataRequest(omElement);
if (parts.length > 0) {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
try {
// This is accessing a class of Commons-FlieUpload
Part.sendParts(bytesOut, parts, format.getMimeBoundary().getBytes());
} catch (IOException e) {
throw AxisFault.makeFault(e);
}
return bytesOut.toByteArray();
}
return new byte[0]; //To change body of implemented methods use File | Settings | File Templates.
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:MultipartFormDataFormatter.java
示例13: testSerializeDeserializeUsingMTOMWithoutOptimize
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
private static void testSerializeDeserializeUsingMTOMWithoutOptimize(Object bean, Object expectedResult) throws Exception {
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
envelope.getBody().addChild(ADBBeanUtil.getOMElement(bean));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
OMOutputFormat format = new OMOutputFormat();
MultipartWriter mpWriter = JavaMailMultipartWriterFactory.INSTANCE.createMultipartWriter(buffer, format.getMimeBoundary());
OutputStream rootPartWriter = mpWriter.writePart("application/xop+xml; charset=UTF-8; type=\"text/xml\"", "binary", format.getRootContentId());
envelope.serialize(rootPartWriter, format);
rootPartWriter.close();
mpWriter.complete();
// System.out.write(buffer.toByteArray());
String contentType = format.getContentTypeForMTOM("text/xml");
Attachments attachments = new Attachments(new ByteArrayInputStream(buffer.toByteArray()), contentType);
MTOMStAXSOAPModelBuilder builder = new MTOMStAXSOAPModelBuilder(StAXUtils.createXMLStreamReader(attachments.getSOAPPartInputStream()), attachments);
OMElement bodyElement = builder.getSOAPEnvelope().getBody().getFirstElement();
assertBeanEquals(expectedResult, ADBBeanUtil.parse(bean.getClass(), bodyElement.getXMLStreamReaderWithoutCaching()));
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:18,代码来源:AbstractTestCase.java
示例14: testPlainOMSerialization
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public void testPlainOMSerialization() throws Exception {
TestLogger.logger.debug("---------------------------------------");
TestLogger.logger.debug("test: " + getName());
OMElement payload = createPayload();
OMOutputFormat format = new OMOutputFormat();
format.setDoOptimize(true);
format.setSOAP11(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
payload.serializeAndConsume(baos, format);
TestLogger.logger.debug("==================================");
TestLogger.logger.debug(baos.toString());
TestLogger.logger.debug("==================================");
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:18,代码来源:MTOMSerializationTests.java
示例15: testSoapOMSerialization
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public void testSoapOMSerialization() throws Exception {
TestLogger.logger.debug("---------------------------------------");
TestLogger.logger.debug("test: " + getName());
OMElement payload = createPayload();
SOAPFactory factory = new SOAP11Factory();
SOAPEnvelope env = factory.createSOAPEnvelope();
SOAPBody body = factory.createSOAPBody(env);
body.addChild(payload);
OMOutputFormat format = new OMOutputFormat();
format.setDoOptimize(true);
format.setSOAP11(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
env.serializeAndConsume(baos, format);
TestLogger.logger.debug("==================================");
TestLogger.logger.debug(baos.toString());
TestLogger.logger.debug("==================================");
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:MTOMSerializationTests.java
示例16: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public String getContentType(MessageContext messageContext, OMOutputFormat format, String soapAction) {
String encoding = format.getCharSetEncoding();
String contentType = (String) messageContext.getProperty(Constants.Configuration.CONTENT_TYPE);
if(contentType == null) {
contentType = org.apache.axis2.namespace.Constants.MIME_CT_TEXT_PLAIN;
}
if (encoding != null) {
contentType += "; charset=" + encoding;
}
// if soap action is there (can be there is soap response MEP is used) add it.
if ((soapAction != null)
&& !"".equals(soapAction.trim())
&& !"\"\"".equals(soapAction.trim())) {
contentType = contentType + ";action=\"" + soapAction + "\";";
}
return contentType;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:21,代码来源:PlainTextFormatter.java
示例17: JsonStreamFormatter
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public JsonStreamFormatter()
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException,
IOException, XMLStreamException {
Class<?> synapseFormatterClass =
JsonStreamFormatter.class.getClassLoader().loadClass(Utils.getPassThroughJsonFormatter());
this.synapseFormatter = synapseFormatterClass.newInstance();
this.synapseFormatterGetBytesMethod =
synapseFormatterClass.getMethod("getBytes", MessageContext.class, OMOutputFormat.class);
this.synapseFormatterWriteToMethod = synapseFormatterClass
.getMethod("writeTo", MessageContext.class, OMOutputFormat.class, OutputStream.class, boolean.class);
this.synapseFormatterGetContentTypeMethod = synapseFormatterClass
.getMethod("getContentType", MessageContext.class, OMOutputFormat.class, String.class);
this.synapseFormatterGetTargetAddressMethod = synapseFormatterClass
.getMethod("getTargetAddress", MessageContext.class, OMOutputFormat.class, URL.class);
this.synapseFormatterFormatSOAPActionMethod = synapseFormatterClass
.getMethod("formatSOAPAction", MessageContext.class, OMOutputFormat.class, String.class);
Class<?> axis2GsonFormatterClass =
JsonStreamFormatter.class.getClassLoader().loadClass(Utils.getDSSJsonFormatter());
this.axis2GsonFormatter = axis2GsonFormatterClass.newInstance();
this.axis2GsonFormatterGetBytesMethod =
axis2GsonFormatterClass.getMethod("getBytes", MessageContext.class, OMOutputFormat.class);
this.axis2GsonFormatterWriteToMethod = axis2GsonFormatterClass
.getMethod("writeTo", MessageContext.class, OMOutputFormat.class, OutputStream.class, boolean.class);
this.axis2GsonFormatterGetContentTypeMethod = axis2GsonFormatterClass
.getMethod("getContentType", MessageContext.class, OMOutputFormat.class, String.class);
this.axis2GsonFormatterGetTargetAddressMethod = axis2GsonFormatterClass
.getMethod("getTargetAddress", MessageContext.class, OMOutputFormat.class, URL.class);
this.axis2GsonFormatterFormatSOAPActionMethod = axis2GsonFormatterClass
.getMethod("formatSOAPAction", MessageContext.class, OMOutputFormat.class, String.class);
}
开发者ID:wso2,项目名称:product-ei,代码行数:32,代码来源:JsonStreamFormatter.java
示例18: getBytes
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public byte[] getBytes(MessageContext messageContext, OMOutputFormat omOutputFormat) throws AxisFault {
try {
if (Utils.isDataService(messageContext)) {
return (byte[]) axis2GsonFormatterGetBytesMethod
.invoke(axis2GsonFormatter, messageContext, omOutputFormat);
} else {
return (byte[]) synapseFormatterGetBytesMethod.invoke(synapseFormatter, messageContext, omOutputFormat);
}
} catch (InvocationTargetException | IllegalAccessException e) {
logger.error("Error occurred while generating bytes for application/json", e);
throw new AxisFault(e.getMessage());
}
}
开发者ID:wso2,项目名称:product-ei,代码行数:14,代码来源:JsonStreamFormatter.java
示例19: writeTo
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public void writeTo(MessageContext messageContext, OMOutputFormat omOutputFormat, OutputStream outputStream,
boolean b) throws AxisFault {
try {
if (Utils.isDataService(messageContext)) {
axis2GsonFormatterWriteToMethod
.invoke(axis2GsonFormatter, messageContext, omOutputFormat, outputStream, b);
} else {
synapseFormatterWriteToMethod.invoke(synapseFormatter, messageContext, omOutputFormat, outputStream, b);
}
} catch (InvocationTargetException | IllegalAccessException e) {
logger.error("Error occurred while writing to application/json", e);
throw new AxisFault(e.getMessage());
}
}
开发者ID:wso2,项目名称:product-ei,代码行数:15,代码来源:JsonStreamFormatter.java
示例20: getContentType
import org.apache.axiom.om.OMOutputFormat; //导入依赖的package包/类
public String getContentType(MessageContext messageContext, OMOutputFormat omOutputFormat, String s) {
try {
if (Utils.isDataService(messageContext)) {
return (String) axis2GsonFormatterGetContentTypeMethod
.invoke(axis2GsonFormatter, messageContext, omOutputFormat, s);
} else {
return (String) synapseFormatterGetContentTypeMethod
.invoke(synapseFormatter, messageContext, omOutputFormat, s);
}
} catch (InvocationTargetException | IllegalAccessException | AxisFault e ) {
logger.error(e.getMessage());
throw new RuntimeException(e.getMessage());
}
}
开发者ID:wso2,项目名称:product-ei,代码行数:15,代码来源:JsonStreamFormatter.java
注:本文中的org.apache.axiom.om.OMOutputFormat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论