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


Java StaxUtils.createXMLStreamReader方法代码示例

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


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

示例1: ElementReader

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
/**
 * @param is
 * @throws javax.xml.stream.XMLStreamException
 */
public ElementReader(InputStream is) throws XMLStreamException {
    // XMLInputFactory factory = XMLInputFactory.newInstance();
    // XMLStreamReader xmlReader = factory.createXMLStreamReader(is);
    XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(is, null);

    xmlReader.nextTag();

    this.root = new DepthXMLStreamReader(xmlReader);
    this.localName = root.getLocalName();
    this.name = root.getName();
    this.namespace = root.getNamespaceURI();

    extractXsiType();

    depth = root.getDepth();
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:21,代码来源:ElementReader.java

示例2: handleMessage

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
	String mappedNamespace = message.getExchange().getService().getName().getNamespaceURI();
	InputStream in = message.getContent(InputStream.class);
	if( in != null )
	{
		// ripped from StaxInInterceptor
		String contentType = (String) message.get(Message.CONTENT_TYPE);
		if( contentType == null )
		{
			// if contentType is null, this is likely a an empty
			// post/put/delete/similar, lets see if it's
			// detectable at all
			Map<String, List<String>> m = CastUtils.cast((Map<?, ?>) message.get(Message.PROTOCOL_HEADERS));
			if( m != null )
			{
				List<String> contentLen = HttpHeaderHelper.getHeader(m, HttpHeaderHelper.CONTENT_LENGTH);
				List<String> contentTE = HttpHeaderHelper.getHeader(m, HttpHeaderHelper.CONTENT_TRANSFER_ENCODING);
				if( (StringUtils.isEmpty(contentLen) || "0".equals(contentLen.get(0)))
					&& StringUtils.isEmpty(contentTE) )
				{
					return;
				}
			}
		}

		// Inject our LegacyPythonHack
		XMLStreamReader reader = StaxUtils.createXMLStreamReader(in);
		message.setContent(XMLStreamReader.class, new LegacyPythonClientXMLStreamReader(reader, mappedNamespace));
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:LegacyPythonClientInInterceptor.java

示例3: handleMessage

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
public void handleMessage(Message message) throws Fault {
    XMLStreamWriter xmlWriter = getXMLStreamWriter(message);
    try {
        // put the payload source as a document
        Source source = message.getContent(Source.class);
        if (source != null) {
            XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(source);
            StaxUtils.copy(xmlReader, xmlWriter);
        }
    } catch (XMLStreamException e) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION", JUL_LOG, e), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:DataOutInterceptor.java

示例4: reserialize

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
private void reserialize(SoapMessage message) throws Exception {
    SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
    if (soapMessage == null) {
        return;
    }

    DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart());
    XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(bodySource);
    message.setContent(XMLStreamReader.class, xmlReader);
}
 
开发者ID:apache,项目名称:tomee,代码行数:11,代码来源:EjbInterceptor.java

示例5: build

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
public Document build(InputStream is) throws XMLStreamException {
    isReadingMidStream = false;
    XMLStreamReader reader = null;
    try {
        reader = StaxUtils.createXMLStreamReader(is);
        return buildInternal(reader);
    } finally {
        StaxUtils.close(reader);
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:11,代码来源:StaxBuilder.java

示例6: testCachedCxfPayloadStaxSource

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
@Test
public void testCachedCxfPayloadStaxSource() throws TypeConversionException, NoTypeConversionAvailableException, IOException {
    XMLStreamReader streamReader = StaxUtils.createXMLStreamReader(new StreamSource(new StringReader(PAYLOAD)));
    StaxSource source = new StaxSource(streamReader);
    doTest(source, PAYLOAD);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:CachedCxfPayloadTest.java

示例7: testGetCxfInMessage

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
@Test
public void testGetCxfInMessage() throws Exception {
    HeaderFilterStrategy headerFilterStrategy = new CxfHeaderFilterStrategy();
    org.apache.camel.Exchange exchange = new DefaultExchange(context);
    // String
    exchange.getIn().setBody("hello world");
    org.apache.cxf.message.Message message = CxfMessageHelper.getCxfInMessage(
            headerFilterStrategy, exchange, false);
    // test message
    InputStream is = message.getContent(InputStream.class);
    assertNotNull("The input stream should not be null", is);
    assertEquals("Don't get the right message", toString(is), "hello world");

    // DOMSource
    URL request = this.getClass().getResource("RequestBody.xml");
    File requestFile = new File(request.toURI());
    FileInputStream inputStream = new FileInputStream(requestFile);
    XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(inputStream);
    DOMSource source = new DOMSource(StaxUtils.read(xmlReader));
    exchange.getIn().setBody(source);
    message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
    is = message.getContent(InputStream.class);
    assertNotNull("The input stream should not be null", is);
    assertEquals("Don't get the right message", toString(is), REQUEST_STRING);

    // File
    exchange.getIn().setBody(requestFile);
    message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
    is = message.getContent(InputStream.class);
    assertNotNull("The input stream should not be null", is);
    assertEquals("Don't get the right message", toString(is), REQUEST_STRING);

    // transport header's case insensitiveness
    // String
    exchange.getIn().setBody("hello world");
    exchange.getIn().setHeader("soapAction", "urn:hello:world");
    message = CxfMessageHelper.getCxfInMessage(headerFilterStrategy, exchange, false);
    // test message
    Map<String, List<String>> headers = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
    
    // verify there is no duplicate
    assertNotNull("The headers must be present", headers);
    assertTrue("There must be one header entry", headers.size() == 1);
    
    // verify the soapaction can be retrieved in case-insensitive ways
    verifyHeader(headers, "soapaction", "urn:hello:world");
    verifyHeader(headers, "SoapAction", "urn:hello:world");
    verifyHeader(headers, "SOAPAction", "urn:hello:world");
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:50,代码来源:CxfMessageHelperTest.java

示例8: handleMessage

import org.apache.cxf.staxutils.StaxUtils; //导入方法依赖的package包/类
@Override
public void handleMessage(SoapMessage message) throws Fault
{
	try
	{
		KeyStore keyStore = SecurityUtils.loadKeyStore(keyStorePath,keyStorePassword);

		XMLStreamReader reader = message.getContent(XMLStreamReader.class);
		Document document = StaxUtils.read(reader);
		XMLStreamReader copy = StaxUtils.createXMLStreamReader(document);
		message.setContent(XMLStreamReader.class,copy);

		List<EbMSDataSource> dataSources = new ArrayList<EbMSDataSource>();
		if (message.getAttachments() != null)
			for (Attachment attachment : message.getAttachments())
				dataSources.add(new EbMSDataSource(attachment.getDataHandler().getDataSource(),attachment.getId(),attachment.getDataHandler().getName()));

		NodeList signatureNodeList = document.getElementsByTagNameNS(org.apache.xml.security.utils.Constants.SignatureSpecNS,org.apache.xml.security.utils.Constants._TAG_SIGNATURE);
		if (signatureNodeList.getLength() > 0)
		{
			boolean isValid = false;
			X509Certificate certificate = getCertificate(document);
			if (certificate != null)
			{
				isValid = validateCertificate(keyStore,certificate,new Date()/*TODO get date from message???*/);
				if (!isValid)
					logger.info("Certificate invalid.");
				else
				{
					isValid = verify(certificate,signatureNodeList,dataSources);
					logger.info("Signature" + (isValid ? " " : " in") + "valid.");
				}
			}
			SignatureManager.set(new Signature(certificate,XMLMessageBuilder.getInstance(SignatureType.class).handle(signatureNodeList.item(0)),isValid));
		}
		else
			SignatureManager.set(null);
	}
	catch (Exception e)
	{
		throw new Fault(e);
	}
}
 
开发者ID:mprins,项目名称:muleebmsadapter,代码行数:44,代码来源:EbMSSecSignatureInInterceptor.java


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