当前位置: 首页>>代码示例>>Java>>正文


Java OMOutputFormat.setSOAP11方法代码示例

本文整理汇总了Java中org.apache.axiom.om.OMOutputFormat.setSOAP11方法的典型用法代码示例。如果您正苦于以下问题:Java OMOutputFormat.setSOAP11方法的具体用法?Java OMOutputFormat.setSOAP11怎么用?Java OMOutputFormat.setSOAP11使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axiom.om.OMOutputFormat的用法示例。


在下文中一共展示了OMOutputFormat.setSOAP11方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: writeTo

import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
/**
 * Writes this <CODE>SOAPMessage</CODE> object to the given output stream. The externalization
 * format is as defined by the SOAP 1.1 with Attachments specification.
 * <p/>
 * <P>If there are no attachments, just an XML stream is written out. For those messages that
 * have attachments, <CODE>writeTo</CODE> writes a MIME-encoded byte stream.</P>
 *
 * @param out the <CODE>OutputStream</CODE> object to which this <CODE>SOAPMessage</CODE> object
 *            will be written
 * @throws SOAPException if there was a problem in externalizing this SOAP message
 * @throws IOException   if an I/O error occurs
 */
public void writeTo(OutputStream out) throws SOAPException, IOException {
    try {
        OMOutputFormat format = new OMOutputFormat();
        String enc = (String)getProperty(CHARACTER_SET_ENCODING);
        format.setCharSetEncoding(enc != null ? enc : OMOutputFormat.DEFAULT_CHAR_SET_ENCODING);
        String writeXmlDecl = (String)getProperty(WRITE_XML_DECLARATION);
        if (writeXmlDecl == null || writeXmlDecl.equals("false")) {

            //SAAJ default case doesn't send XML decl
            format.setIgnoreXMLDeclaration(true);
        }

        SOAPEnvelope envelope = ((SOAPEnvelopeImpl)soapPart.getEnvelope()).getOMEnvelope();
        if (attachmentParts.isEmpty()) {
            envelope.serialize(out, format);
        } else {
            format.setSOAP11(((SOAPEnvelopeImpl)soapPart.getEnvelope()).getOMFactory()
                    instanceof SOAP11Factory);
            OMMultipartWriter mpw = new OMMultipartWriter(out, format);
            OutputStream rootPartOutputStream = mpw.writeRootPart();
            envelope.serialize(rootPartOutputStream);
            rootPartOutputStream.close();
            for (AttachmentPart ap : attachmentParts) {
                mpw.writePart(ap.getDataHandler(), ap.getContentId());
            }
            mpw.complete();
        }
        saveChanges();
    } catch (Exception e) {
        throw new SOAPException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:45,代码来源:SOAPMessageImpl.java

示例5: testMTOMAttachmentWriter

import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public void testMTOMAttachmentWriter() throws Exception {
    TestLogger.logger.debug("---------------------------------------");
    TestLogger.logger.debug("test: " + getName());
    
    //Create a DataHandler with the String DataSource object
    DataHandler dataHandler = new DataHandler(imageDS);
                    
    //Store the data handler in ImageDepot bean
    ImageDepot imageDepot = new ObjectFactory().createImageDepot();
    imageDepot.setImageData(dataHandler);
    
    //JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
    JAXBBlockContext context = new JAXBBlockContext(SendImage.class.getPackage().getName());
    
    //Create a request bean with imagedepot bean as value
    ObjectFactory factory = new ObjectFactory();
    SendImage request = factory.createSendImage();
    request.setInput(imageDepot);
    
    BlockFactory blkFactory = (JAXBBlockFactory) FactoryRegistry.getFactory(JAXBBlockFactory.class);
    Block block = blkFactory.createFrom(request, context, null);
    
    MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
    Message msg = msgFactory.create(Protocol.soap11);
    
    msg.setBodyBlock(block);
    
    msg.setMTOMEnabled(true);
    
    SOAPEnvelope soapOM = (SOAPEnvelope) msg.getAsOMElement();
    
    OMOutputFormat format = new OMOutputFormat();
    format.setDoOptimize(true);
    format.setSOAP11(true);
           
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    soapOM.serializeAndConsume(baos, format);
    String outputText = baos.toString();
    // Make sure the attachment is serialized
    assertTrue(outputText.indexOf("Content-Type: image/jpeg") > 0);

    TestLogger.logger.debug("==================================");
    TestLogger.logger.debug(outputText);
    TestLogger.logger.debug("==================================");
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:46,代码来源:MTOMSerializationTests.java

示例6: testMTOMAttachmentWriter2

import org.apache.axiom.om.OMOutputFormat; //导入方法依赖的package包/类
public void testMTOMAttachmentWriter2() throws Exception {
    TestLogger.logger.debug("---------------------------------------");
    TestLogger.logger.debug("test: " + getName());
    
    //Create a DataHandler with the String DataSource object
    DataHandler dataHandler = new DataHandler(imageDS);
                    
    //Store the data handler in ImageDepot bean
    ImageDepot imageDepot = new ObjectFactory().createImageDepot();
    imageDepot.setImageData(dataHandler);
    
    //JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
    JAXBBlockContext context = new JAXBBlockContext(SendImage.class.getPackage().getName());
    
    //Create a request bean with imagedepot bean as value
    ObjectFactory factory = new ObjectFactory();
    SendImage request = factory.createSendImage();
    request.setInput(imageDepot);
    
    BlockFactory blkFactory = (JAXBBlockFactory) FactoryRegistry.getFactory(JAXBBlockFactory.class);
    Block block = blkFactory.createFrom(request, context, null);
    
    MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
    Message msg = msgFactory.create(Protocol.soap11);
    
    msg.setBodyBlock(block);
    
    msg.setMTOMEnabled(true);
    
    // Convert message to SAAJ to simulate an outbound handler
    msg.getAsSOAPMessage();
    
    // Now convert it back to AXIOM
    
    SOAPEnvelope soapOM = (SOAPEnvelope) msg.getAsOMElement();
    
    OMOutputFormat format = new OMOutputFormat();
    format.setDoOptimize(true);
    format.setSOAP11(true);
           
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    soapOM.serializeAndConsume(baos, format);
    String outputText = baos.toString();
    // Make sure the attachment is serialized
    assertTrue(outputText.indexOf("Content-Type: image/jpeg") > 0);

    TestLogger.logger.debug("==================================");
    TestLogger.logger.debug(outputText);
    TestLogger.logger.debug("==================================");
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:51,代码来源:MTOMSerializationTests.java


注:本文中的org.apache.axiom.om.OMOutputFormat.setSOAP11方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。