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


Java StAXUtils.createXMLStreamReader方法代码示例

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


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

示例1: getBuilder

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
 * Creates an OMBuilder for a plain XML message.
 *
 * @param inStream   InputStream for a XML message
 * @param charSetEnc Character set encoding to be used
 * @return Handler to a OMBuilder implementation instance
 * @throws javax.xml.stream.XMLStreamException
 */
public static StAXBuilder getBuilder(InputStream inStream, String charSetEnc) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                    new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:24,代码来源:XMLUtil.java

示例2: getSOAPBuilder

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
 * Creates an OMBuilder for a SOAP message. Default character set encording is used.
 *
 * @param inStream InputStream for a SOAP message
 * @return Handler to a OMBuilder implementation instance
 * @throws javax.xml.stream.XMLStreamException
 */
public static StAXBuilder getSOAPBuilder(InputStream inStream) throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                    new String(IOUtils.getStreamAsByteArray(inStream) , "UTF-8") + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-gateway-framework,代码行数:23,代码来源:XMLUtil.java

示例3: getSOAPBuilder

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
 * Creates an OMBuilder for a SOAP message.
 *
 * @param inStream   InputStream for a SOAP message
 * @param charSetEnc Character set encoding to be used
 * @return Handler to a OMBuilder implementation instance
 * @throws XMLStreamException
 */
public static StAXBuilder getSOAPBuilder(InputStream inStream, String charSetEnc)
        throws XMLStreamException {
    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(inStream, charSetEnc);
    try {
        return new StAXSOAPModelBuilder(xmlReader);
    } catch (OMException e) {
        log.info("OMException in getSOAPBuilder", e);
        try {
            log.info("Remaining input stream :[" +
                     new String(IOUtils.getStreamAsByteArray(inStream), charSetEnc) + "]");
        } catch (IOException e1) {
            // Nothing here?
        }
        throw e;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:BuilderUtil.java

示例4: getInputObject

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
protected Object[] getInputObject(List inputObjects, Operation operation)
        throws XMLStreamException, XmlSerializingException, XmlParsingException {
    StringWriter inputStringWriter = new StringWriter();
    XMLStreamWriter inputXmlStreamWriter = StAXUtils.createXMLStreamWriter(inputStringWriter);
    this.javaObjectSerializer.serializeInputElement(inputObjects.toArray(),
            operation.getInputElement(),
            operation.getInputParameters(),
            inputXmlStreamWriter);
    inputXmlStreamWriter.flush();
    String inputXmlString = inputStringWriter.toString();

    System.out.println("input Xml String ==> " + inputXmlString);

    XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(inputXmlString.getBytes()));
    Object[] objects = this.xmlStreamParser.getInputParameters(xmlReader, operation);
    return objects;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:18,代码来源:RequestResponseTest.java

示例5: toOM

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
private org.apache.axiom.soap.SOAPEnvelope toOM(String xml)
        throws WebServiceException {
	if (log.isDebugEnabled()) {
	    log.debug("Converting SAAJ SOAPEnvelope String to an OM SOAPEnvelope");
	    log.debug("The conversion occurs due to " + JavaUtils.stackToString());
	} 
	
    XMLStreamReader reader;
    try {
        reader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xml.getBytes()));
    } catch (XMLStreamException e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
    // Get a SOAP OM Builder.  Passing null causes the version to be automatically triggered
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader, null);
    // Create and return the OM Envelope
    return builder.getSOAPEnvelope();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:SAAJConverterImpl.java

示例6: _postPivot_getXMLStreamReader

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
 * Called if we have passed the pivot point but someone wants to output the block. The actual
 * block implementation may choose to override this setting.
 */
protected XMLStreamReader _postPivot_getXMLStreamReader()
        throws XMLStreamException, WebServiceException {
    if (log.isDebugEnabled()) {
        QName theQName = isQNameAvailable() ? getQName() : new QName("unknown");
        log.debug("The Block for " + theQName +
                " is already consumed and therefore it is only partially read.");
        log.debug("If you need this block preserved, please set the " + Constants
                .SAVE_REQUEST_MSG + " property on the MessageContext.");
    }
    QName qName = getQName();
    String text = "";
    if (qName.getNamespaceURI().length() > 0) {
        text = "<prefix:" + qName.getLocalPart() + " xmlns:prefix='" + qName.getNamespaceURI() +
                "'/>";
    } else {
        text = "<" + qName.getLocalPart() + "/>";
    }
    StringReader sr = new StringReader(text);
    return StAXUtils.createXMLStreamReader(sr);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:BlockImpl.java

示例7: testSerializeDeserializeUsingMTOMWithoutOptimize

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的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

示例8: buildOMElement

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
private static OMElement buildOMElement() {
    String xmlString = "<ns1:Project xmlns:ns1=\"http://axis2.apache.org/sample\">\n" +
            "    <ns1:Developer>\n" +
            "        <ns1:name>AAA</ns1:name>\n" +
            "        <ns1:location>Colombo</ns1:location>\n" +
            "    </ns1:Developer>\n" +
            "</ns1:Project>";
    OMElement omElement = null;
    try {
        XMLStreamReader xmlStreamReader =
                StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
        StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(xmlStreamReader);
        omElement = stAXOMBuilder.getDocumentElement();
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    return omElement;
}
 
开发者ID:syodage,项目名称:Axis2-Samples,代码行数:19,代码来源:OMElementBuilder.java

示例9: buildSoapEnvelope

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
private static SOAPEnvelope buildSoapEnvelope() {

        String xmlString = "<soapenv:Envelope xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">\n" +
                "    <soapenv:Body>\n" +
                "        <ns1:Project xmlns:ns1=\"http://axis2.apache.org/sample\">\n" +
                "            <ns1:Developer>\n" +
                "                <ns1:name>AAA</ns1:name>\n" +
                "                <ns1:location>Colombo</ns1:location>\n" +
                "            </ns1:Developer>\n" +
                "        </ns1:Project>\n" +
                "    </soapenv:Body>\n" +
                "</soapenv:Envelope>";

        SOAPEnvelope soapEnvelope = null;
        try {
            XMLStreamReader xmlStreamReader =
                    StAXUtils.createXMLStreamReader(new ByteArrayInputStream(xmlString.getBytes()));
            StAXSOAPModelBuilder stAXSOAPModelBuilder = new StAXSOAPModelBuilder(xmlStreamReader);
            soapEnvelope = stAXSOAPModelBuilder.getSOAPEnvelope();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        }
        return soapEnvelope;
    }
 
开发者ID:syodage,项目名称:Axis2-Samples,代码行数:25,代码来源:SoapElementBuilder.java

示例10: getBSTHeader

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
private String getBSTHeader(Request request) throws IOException, XMLStreamException {
    org.apache.coyote.Request coyoteReq = request.getCoyoteRequest();
    InputBuffer buf = coyoteReq.getInputBuffer();
    ByteChunk bc = new ByteChunk();

    buf.doRead(bc, coyoteReq);
    try (InputStream is = new ByteArrayInputStream(getUTF8Bytes(bc.toString()))) {
        XMLStreamReader reader = StAXUtils.createXMLStreamReader(is);
        StAXBuilder builder = new StAXSOAPModelBuilder(reader);
        SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
        envelope.build();

        SOAPHeader header = envelope.getHeader();
        Iterator headerEls = header.getChildrenWithLocalName("Security");
        if (!headerEls.hasNext()) {
            return null;
        }
        OMElement securityHeader = (OMElement) headerEls.next();
        Iterator securityHeaderEls = securityHeader.getChildrenWithLocalName("BinarySecurityToken");
        if (!securityHeaderEls.hasNext()) {
            return null;
        }
        OMElement bstHeader = (OMElement) securityHeaderEls.next();
        bstHeader.build();
        return bstHeader.getText();
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:28,代码来源:BSTAuthenticator.java

示例11: getEnvelope

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
 * Create a SOAP envelope using SOAP 1.1 or 1.2 depending on the namespace
 * @param in InputStream for the payload
 * @param namespace the SOAP namespace
 * @return the SOAP envelope for the correct version
 * @throws javax.xml.stream.XMLStreamException on error
 */
public static SOAPEnvelope getEnvelope(InputStream in, String namespace) throws XMLStreamException {

    try {
        in.reset();
    } catch (IOException ignore) {}
    XMLStreamReader xmlreader =
        StAXUtils.createXMLStreamReader(in, MessageContext.DEFAULT_CHAR_SET_ENCODING);
    StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, namespace);
    return (SOAPEnvelope) builder.getDocumentElement();
}
 
开发者ID:wso2,项目名称:wso2-axis2-transports,代码行数:18,代码来源:BaseUtils.java

示例12: process

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
 *  Simple reusable method to make object instances via reflection
 * @param testString
 * @param className
 * @return
 * @throws Exception
 */
protected Object process(String testString,String className) throws Exception{
    XMLStreamReader reader = StAXUtils.createXMLStreamReader(new ByteArrayInputStream(testString.getBytes()));
    Class clazz = Class.forName(className);
    Class innerClazz = Util.getFactory(clazz);
    Method parseMethod = innerClazz.getMethod("parse",new Class[]{XMLStreamReader.class});
    Object obj = parseMethod.invoke(null,new Object[]{reader});
    assertNotNull(obj);

    return obj;

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:AbstractSimplePopulater.java

示例13: mapXmlStream

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
/**
 * Load a mapping input stream  and save it to the map
 * @param map target map file
 * @param packageIsKey if the package is to be the key for the map
 * @throws BuildException if an IOException needed swallowing
 */
protected void mapXmlStream(HashMap map, boolean packageIsKey) throws BuildException {
    try {
        mapXmlReader = StAXUtils.createXMLStreamReader(mapInputStream);
        mapXmlReader(map, packageIsKey);
        //ensure this clean up so that the next invocation does not have any stale state
        mapXmlReader = null;
    } catch ( Exception e ) {
        throw new BuildException(e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:NamespaceMapping.java

示例14: createSOAPEnvelope

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
public SOAPEnvelope createSOAPEnvelope(InputStream in) throws AxisFault {
    try {
        XMLStreamReader xmlreader =
                StAXUtils.createXMLStreamReader(in);
        StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, null);
        return (SOAPEnvelope) builder.getDocumentElement();
    } catch (Exception e) {
        throw new AxisFault(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:11,代码来源:TCPTransportTest.java

示例15: testStateMachine2

import org.apache.axiom.om.util.StAXUtils; //导入方法依赖的package包/类
public void testStateMachine2() throws Exception {
    String xmlDoc = "<wrapper><myIntVal>200</myIntVal></wrapper>";
    XMLStreamReader reader = StAXUtils.createXMLStreamReader(
            new StringReader(xmlDoc));
    SimpleArrayReaderStateMachine sm = new SimpleArrayReaderStateMachine();
    sm.setElementNameToTest(new QName("myIntVal"));
    try {
        sm.read(reader);
    } catch (XMLStreamException e) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }

    assertEquals("200", sm.getTextArray()[0]);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:15,代码来源:SimpleArrayReaderStateMachineTest.java


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