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


Java OMElement.getOMFactory方法代码示例

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


在下文中一共展示了OMElement.getOMFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uploadFileUsingSwA

import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement uploadFileUsingSwA(OMElement request) throws Exception {

        String imageContentId = request.
            getFirstChildWithName(new QName("http://services.samples", "request")).
            getFirstChildWithName(new QName("http://services.samples", "imageId")).
            getText();

        MessageContext msgCtx   = MessageContext.getCurrentMessageContext();
        Attachments attachment  = msgCtx.getAttachmentMap();
        DataHandler dataHandler = attachment.getDataHandler(imageContentId);
        File tempFile = File.createTempFile("swa-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        dataHandler.writeTo(fos);
		fos.flush();
		fos.close();
        System.out.println("Wrote SwA attachment to temp file : " + tempFile.getAbsolutePath());

        MessageContext outMsgCtx = msgCtx.getOperationContext().
            getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
        outMsgCtx.setProperty(
            org.apache.axis2.Constants.Configuration.ENABLE_SWA,
            org.apache.axis2.Constants.VALUE_TRUE);

        OMFactory factory = request.getOMFactory();
        OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
        OMElement payload  = factory.createOMElement("uploadFileUsingSwAResponse", ns);
        OMElement response = factory.createOMElement("response", ns);
        OMElement imageId  = factory.createOMElement("imageId", ns);

        FileDataSource fileDataSource = new FileDataSource(tempFile);
        dataHandler = new DataHandler(fileDataSource);
        imageContentId = outMsgCtx.addAttachment(dataHandler);
        imageId.setText(imageContentId);
        response.addChild(imageId);
        payload.addChild(response);

        return payload;
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:39,代码来源:MTOMSwASampleService.java

示例2: uploadFileUsingMTOM

import org.apache.axiom.om.OMElement; //导入方法依赖的package包/类
public OMElement uploadFileUsingMTOM(OMElement request) throws Exception {

        OMText binaryNode = (OMText) request.
            getFirstChildWithName(new QName("http://services.samples", "request")).
            getFirstChildWithName(new QName("http://services.samples", "image")).
            getFirstOMChild();
        DataHandler dataHandler = (DataHandler) binaryNode.getDataHandler();
        InputStream is = dataHandler.getInputStream();

        File tempFile = File.createTempFile("mtom-", ".gif");
        FileOutputStream fos = new FileOutputStream(tempFile);
        BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER);

        byte data[] = new byte[BUFFER];
        int count;
        while ((count = is.read(data, 0, BUFFER)) != -1) {
            dest.write(data, 0, count);
        }

        dest.flush();
        dest.close();
        System.out.println("Wrote MTOM content to temp file : " + tempFile.getAbsolutePath());

        OMFactory factory = request.getOMFactory();
        OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
        OMElement payload  = factory.createOMElement("uploadFileUsingMTOMResponse", ns);
        OMElement response = factory.createOMElement("response", ns);
        OMElement image    = factory.createOMElement("image", ns);

        FileDataSource fileDataSource = new FileDataSource(tempFile);
        dataHandler = new DataHandler(fileDataSource);
        OMText textData = factory.createOMText(dataHandler, true);
        image.addChild(textData);
        response.addChild(image);
        payload.addChild(response);

        MessageContext outMsgCtx = MessageContext.getCurrentMessageContext()
            .getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
        outMsgCtx.setProperty(
            org.apache.axis2.Constants.Configuration.ENABLE_MTOM,
            org.apache.axis2.Constants.VALUE_TRUE);

        return payload;
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:45,代码来源:MTOMSwASampleService.java


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