本文整理汇总了Java中org.apache.axiom.om.impl.builder.StAXBuilder类的典型用法代码示例。如果您正苦于以下问题:Java StAXBuilder类的具体用法?Java StAXBuilder怎么用?Java StAXBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StAXBuilder类属于org.apache.axiom.om.impl.builder包,在下文中一共展示了StAXBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBuilder
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的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.impl.builder.StAXBuilder; //导入依赖的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: closeStaxBuilder
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的package包/类
/**
* Close the builders.
*
* @param messageContext
* @throws ServletException
*/
void closeStaxBuilder(MessageContext messageContext) throws ServletException {
if (closeReader && messageContext != null) {
try {
SOAPEnvelope envelope = messageContext.getEnvelope();
if(envelope != null) {
StAXBuilder builder = (StAXBuilder) envelope.getBuilder();
if (builder != null) {
builder.close();
}
}
} catch (Exception e) {
log.debug(e.toString(), e);
}
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:AxisServlet.java
示例4: getBuilder
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的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 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,项目名称:wso2-axis2,代码行数:25,代码来源:BuilderUtil.java
示例5: getSOAPBuilder
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的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 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)) + "]");
} catch (IOException e1) {
// Nothing here?
}
throw e;
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:BuilderUtil.java
示例6: getBSTHeader
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的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
示例7: getEnvelope
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的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
示例8: processDocument
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的package包/类
/**
* Returns a OMElement handler to the document element of the Fast Infoset message.
*
* @param inputStream InputStream to the message
* @param contentType Content type of the message
* @param messageContext MessageContext to be used
*
* @return OMElement handler to the document element
*
* @see org.apache.axis2.builder.Builder#processDocument(InputStream, String, MessageContext)
*/
public OMElement processDocument(InputStream inputStream, String contentType,
MessageContext messageContext) throws AxisFault {
if (logger.isDebugEnabled()) {
logger.debug("Processing a Document with the content type: " + contentType);
}
//Create a instance of the StAX Parser which can handle the fast infoset stream
XMLStreamReader streamReader = new StAXDocumentParser(inputStream);
StAXBuilder builder = new StAXOMBuilder(streamReader);
return builder.getDocumentElement();
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:FastInfosetPOXBuilder.java
示例9: processDocument
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的package包/类
/**
* Returns a OMElement handler to the document element of the Fast Infoset message.
*
* @param inputStream InputStream to the message
* @param contentType Content type of the message
* @param messageContext MessageContext to be used
*
* @return OMElement handler to the document element
*
* @see org.apache.axis2.builder.Builder#processDocument(InputStream, String, MessageContext)
*/
public OMElement processDocument(InputStream inputStream, String contentType,
MessageContext messageContext) throws AxisFault {
if (logger.isDebugEnabled()) {
logger.debug("Processing a Document with the content type: " + contentType);
}
//Create a instance of the StAX Parser which can handle the fast infoset stream
XMLStreamReader streamReader = new StAXDocumentParser(inputStream);
StAXBuilder builder = new StAXSOAPModelBuilder(streamReader);
return builder.getDocumentElement();
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:FastInfosetBuilder.java
示例10: testInputOutput
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的package包/类
/**
* This is to test how fast infoset interoperate with Axiom.
* This is how this test is organized.
* <pre>
* de-ser(wstx) ser(fast-info) de-ser(fast-info) ser(wstx)
* XML --------> Axiom ------> binary file --------------> Axiom ---------> XML
* </pre>
* <p/>
* Then the initial XML file and the last XML will be compared to see whether they are the same.
*/
public void testInputOutput() throws Exception {
String inputFile = "pom.xml";
File outputFile = new File("target/output.xml");
File tempFile = new File("target/test.bin");
try {
// first let's read the xml document in to Axiom
OMElement element = new StAXOMBuilder(inputFile).getDocumentElement();
// output it using binary xml outputter
XMLStreamWriter streamWriter = new StAXDocumentSerializer(new FileOutputStream(tempFile));
streamWriter.writeStartDocument();
element.serializeAndConsume(streamWriter);
streamWriter.writeEndDocument();
// now let's read the binary file in to Axiom
XMLStreamReader streamReader = new StAXDocumentParser(new FileInputStream(tempFile));
StAXBuilder builder = new StAXOMBuilder(streamReader);
builder.getDocumentElement().serialize(new FileWriter(outputFile));
// let's see this is the same that we fed in to this test initially
assertXMLEqual(new FileReader(inputFile), new FileReader(outputFile));
} finally {
if (outputFile.exists()) outputFile.delete();
if (tempFile.exists()) tempFile.delete();
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:39,代码来源:FastInfosetInputOutputTest.java
示例11: getSOAPFactory
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的package包/类
/**
* Get an axiom SOAPFactory for the specified element
*
* @param e OMElement
* @return SOAPFactory
*/
public static SOAPFactory getSOAPFactory(OMElement e) {
// Getting a factory from a SOAPEnvelope is not straight-forward.
// Please change this code if an easier mechanism is discovered.
OMXMLParserWrapper builder = e.getBuilder();
if (builder instanceof StAXBuilder) {
StAXBuilder staxBuilder = (StAXBuilder)builder;
OMDocument document = staxBuilder.getDocument();
if (document != null) {
OMFactory factory = document.getOMFactory();
if (factory instanceof SOAPFactory) {
return (SOAPFactory)factory;
}
}
}
// Flow to here indicates that the envelope does not have
// an accessible factory. Create a new factory based on the
// protocol.
while (e != null && !(e instanceof SOAPEnvelope)) {
e = (OMElement)e.getParent();
}
if (e instanceof SOAPEnvelope) {
if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.
equals(e.getNamespace().getNamespaceURI())) {
return OMAbstractFactory.getSOAP11Factory();
} else {
return OMAbstractFactory.getSOAP12Factory();
}
}
return null;
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:39,代码来源:MessageUtils.java
示例12: close
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的package包/类
public void close() {
OMElement om = getContentAsOMElement();
if (om !=null) {
OMXMLParserWrapper builder = om.getBuilder();
if (builder instanceof StAXBuilder) {
StAXBuilder staxBuilder = (StAXBuilder) builder;
staxBuilder.releaseParserOnClose(true);
if (!staxBuilder.isClosed()) {
staxBuilder.close();
}
}
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:XMLPartBase.java
示例13: getAttachmentsBuilder
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的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);
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:38,代码来源:BuilderUtil.java
示例14: createSOAPEnvelope
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的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: readElement
import org.apache.axiom.om.impl.builder.StAXBuilder; //导入依赖的package包/类
private static OMElement readElement() throws XMLStreamException {
//Create an input stream for the string
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(sampleXML.getBytes());
//create a builder. Since we want the XML as a plain XML, we can just use
//the plain OMBuilder
StAXBuilder builder = new StAXOMBuilder(byteArrayInputStream);
//return the root element.
return builder.getDocumentElement();
}
开发者ID:syodage,项目名称:Axis2-Samples,代码行数:10,代码来源:OMXpathNavigator.java
注:本文中的org.apache.axiom.om.impl.builder.StAXBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论