• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StaxUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createRouteBuilder

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            from(fromURI).process(new Processor() {
                public void process(final Exchange exchange) throws Exception {
                    QName faultCode = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server");
                    SoapFault fault = new SoapFault("Get the null value of person name", faultCode);
                    Element details = StaxUtils.read(new StringReader(DETAILS)).getDocumentElement();
                    fault.setDetail(details);
                    exchange.setException(fault);
                    
                }
            });
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CxfConsumerPayloadFaultTest.java


示例2: writeTo

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Override
public void writeTo(OutputStream os) throws IOException {
    // no body no write
    if (getBodySources().size() == 0) {
        return;
    }
    Source body = getBodySources().get(0);
    if (body instanceof StreamCache) {
        ((StreamCache) body).writeTo(os);
    } else {
        try {
            StaxUtils.copy(body, os);
        } catch (XMLStreamException e) {
            throw new IOException("Transformation failed", e);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CachedCxfPayload.java


示例3: createRouteBuilder

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            from(fromURI).process(new Processor() {
                public void process(final Exchange exchange) throws Exception {
                    Element details = StaxUtils.read(new StringReader(FAULTS)).getDocumentElement();
                    List<Element> outElements = new ArrayList<Element>();
                    outElements.add(details);
                    CxfPayload<SoapHeader> responsePayload = new CxfPayload<SoapHeader>(null, outElements);
                    exchange.getOut().setBody(responsePayload);
                    exchange.getOut().setFault(true);
                }
            });
            
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:CxfConsumerPayLoadFaultMessageTest.java


示例4: invokeStream

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
public SOAPMessage invokeStream(InputStream in) {
    SOAPMessage response = null;
    try {
        Document doc = StaxUtils.read(in);
        if (doc.getElementsByTagNameNS(greetMe.getNamespaceURI(), 
                                       sayHi.getLocalPart()).getLength() == 1) {
            response = sayHiResponse;
        } else if (doc.getElementsByTagNameNS(greetMe.getNamespaceURI(), 
                                              greetMe.getLocalPart()).getLength() == 1) {
            response = greetMeResponse;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return response;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:SoapTargetBean.java


示例5: createRouteBuilder

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            from(fromURI).process(new Processor() {
                public void process(final Exchange exchange) throws Exception {
                    JAXBContext context = JAXBContext.newInstance("org.apache.camel.wsdl_first.types");
                    QName faultCode = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Server");
                    SoapFault fault = new SoapFault("Get the null value of person name", faultCode);
                    Element details = StaxUtils.read(new StringReader(DETAILS)).getDocumentElement();
                    UnknownPersonFault unknowPersonFault = new UnknownPersonFault();
                    unknowPersonFault.setPersonId("");
                    context.createMarshaller().marshal(unknowPersonFault, details);
                    fault.setDetail(details);
                    exchange.getOut().setBody(fault);
                    exchange.getOut().setFault(true);
                }
            });
            
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:CxfConsumerPayLoadMarshalFaultTest.java


示例6: process

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
public void process(Exchange exchange) throws Exception {
    List<SoapHeader> soapHeaders = CastUtils.cast((List<?>)exchange.getIn().getHeader(Header.HEADER_LIST));
   
    // Insert a new header
    String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><outofbandHeader "
        + "xmlns=\"http://cxf.apache.org/outofband/Header\" hdrAttribute=\"testHdrAttribute\" "
        + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" soap:mustUnderstand=\"1\">"
        + "<name>New_testOobHeader</name><value>New_testOobHeaderValue</value></outofbandHeader>";
    
    SoapHeader newHeader = new SoapHeader(soapHeaders.get(0).getName(),
                                          StaxUtils.read(new StringReader(xml)).getDocumentElement());
    // make sure direction is IN since it is a request message.
    newHeader.setDirection(Direction.DIRECTION_IN);
    //newHeader.setMustUnderstand(false);
    soapHeaders.add(newHeader);
    
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CxfMessageHeadersRelayTest.java


示例7: testConsumer

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Test
public void testConsumer() throws Exception {
    if (MtomTestHelper.isAwtHeadless(logger, null)) {
        return;
    }

    context.createProducerTemplate().send("cxf:bean:consumerEndpoint", new Processor() {

        public void process(Exchange exchange) throws Exception {
            exchange.setPattern(ExchangePattern.InOut);
            assertEquals("Get a wrong Content-Type header", "application/xop+xml", exchange.getIn().getHeader("Content-Type"));
            List<Source> elements = new ArrayList<Source>();
            elements.add(new DOMSource(StaxUtils.read(new StringReader(getRequestMessage())).getDocumentElement()));
            CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
                elements, null);
            exchange.getIn().setBody(body);
            exchange.getIn().addAttachment(MtomTestHelper.REQ_PHOTO_CID, 
                new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));

            exchange.getIn().addAttachment(MtomTestHelper.REQ_IMAGE_CID, 
                new DataHandler(new ByteArrayDataSource(MtomTestHelper.requestJpeg, "image/jpeg")));
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:CxfMtomConsumerPayloadModeTest.java


示例8: process

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void process(Exchange exchange) throws Exception {
    CxfPayload<SoapHeader> in = exchange.getIn().getBody(CxfPayload.class);
    
    // verify request
    Assert.assertEquals(1, in.getBody().size());
    
    DataHandler dr = exchange.getIn().getAttachment(MtomTestHelper.REQ_PHOTO_CID);
    Assert.assertEquals("application/octet-stream", dr.getContentType());
    MtomTestHelper.assertEquals(MtomTestHelper.REQ_PHOTO_DATA, IOUtils.readBytesFromStream(dr.getInputStream()));
       
    dr = exchange.getIn().getAttachment(MtomTestHelper.REQ_IMAGE_CID);
    Assert.assertEquals("image/jpeg", dr.getContentType());
    MtomTestHelper.assertEquals(MtomTestHelper.requestJpeg, IOUtils.readBytesFromStream(dr.getInputStream()));

    // create response
    List<Source> elements = new ArrayList<Source>();
    elements.add(new DOMSource(StaxUtils.read(new StringReader(MtomTestHelper.MTOM_DISABLED_RESP_MESSAGE)).getDocumentElement()));
    CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
        elements, null);
    exchange.getOut().setBody(body);
    exchange.getOut().addAttachment(MtomTestHelper.RESP_PHOTO_CID, 
        new DataHandler(new ByteArrayDataSource(MtomTestHelper.RESP_PHOTO_DATA, "application/octet-stream")));

    exchange.getOut().addAttachment(MtomTestHelper.RESP_IMAGE_CID, 
        new DataHandler(new ByteArrayDataSource(MtomTestHelper.responseJpeg, "image/jpeg")));

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:29,代码来源:CxfMtomDisabledConsumerPayloadModeTest.java


示例9: getNode

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
public synchronized Node getNode() {
	Node nd = super.getNode();
	if (nd == null) {
		try {
			InputSource src = new InputSource(resource.openStream());
			src.setSystemId(this.getSystemId());
			src.setPublicId(publicId);
			Document doc = StaxUtils.read(src);
			setNode(doc);
			nd = super.getNode();
		} catch (Exception ex) {
			throw new RuntimeException(ex);
		}
	}
	return nd;
}
 
开发者ID:GeeQuery,项目名称:cxf-plus,代码行数:17,代码来源:JAXBDataBinding.java


示例10: getPrefixForNamespace

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
public String getPrefixForNamespace(String ns) {
    try {
        String pfx = writer.getPrefix(ns);

        if (pfx == null) {
            pfx = StaxUtils.getUniquePrefix(writer);

            writer.setPrefix(pfx, ns);
            writer.writeNamespace(pfx, ns);
        }

        return prefix;
    } catch (XMLStreamException e) {
        throw new DatabindingException("Error writing document.", e);
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:17,代码来源:ElementWriter.java


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


示例12: writeObject

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Override
public void writeObject(Object object, MessageWriter writer, 
                        Context context) throws DatabindingException {
    Document doc = (Document)object;

    try {
        Element docElement = doc.getDocumentElement();
        if (docElement == null) {
            if (isNillable()) {
                writer.writeXsiNil();
            } else {
                throw new DatabindingException("Could not write xml: null document element.");
            }
        } else {
            StaxUtils.writeElement(docElement, ((ElementWriter)writer).getXMLStreamWriter(), false);
        }
    } catch (XMLStreamException e) {
        throw new DatabindingException("Could not write xml.", e);
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:21,代码来源:DocumentType.java


示例13: write

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
protected void write(Source object, XMLStreamWriter writer) throws FactoryConfigurationError,
    XMLStreamException, DatabindingException {
    if (object == null) {
        return;
    }

    if (object instanceof DOMSource) {
        DOMSource ds = (DOMSource)object;

        Element element = null;
        if (ds.getNode() instanceof Element) {
            element = (Element)ds.getNode();
        } else if (ds.getNode() instanceof Document) {
            element = ((Document)ds.getNode()).getDocumentElement();
        } else {
            throw new DatabindingException("Node type " + ds.getNode().getClass()
                                           + " was not understood.");
        }

        StaxUtils.writeElement(element, writer, false);
    } else {
        StaxUtils.copy(object, writer);
    }
}
 
开发者ID:claudemamo,项目名称:jruby-cxf,代码行数:25,代码来源:SourceType.java


示例14: publishEndpointWithMtom

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Test
public void publishEndpointWithMtom() throws Exception {

    jaxwsEnvironment.publishEndpoint(
            new EndpointBuilder("local://path", service)
                    .enableMtom());

    verify(mockInvokerBuilder).create(any(), any(Invoker.class));

    byte[] response = testutils.invokeBytes("local://path", LocalTransportFactory.TRANSPORT_ID, soapRequest.getBytes());

    verify(mockInvoker).invoke(any(Exchange.class), any());

    MimeMultipart mimeMultipart = new MimeMultipart(new ByteArrayDataSource(response,
            "application/xop+xml; charset=UTF-8; type=\"text/xml\""));
    assertThat(mimeMultipart.getCount(), equalTo(1));
    testutils.assertValid("/soap:Envelope/soap:Body/a:fooResponse",
            StaxUtils.read(mimeMultipart.getBodyPart(0).getInputStream()));
}
 
开发者ID:roskart,项目名称:dropwizard-jaxws,代码行数:20,代码来源:JAXWSEnvironmentTest.java


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


示例16: write

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
@Override
	public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
		QName rootElement = part.getElementQName();
		Element serialized;
		try {
			serialized = prismContex.domSerializer().serializeAnyData(obj, rootElement);
			StaxUtils.copy(serialized, output);
//			output.writeCharacters(serialized);
		} catch (SchemaException | XMLStreamException e) {
			// TODO Auto-generated catch block
			throw new Fault(e);
		}
		
		
	}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:16,代码来源:CustomDataWriter.java


示例17: handleMessage

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
public void handleMessage(Message message) throws Fault {

        Document doc = (Document)message.get(RawMessageWSDLGetInterceptor.DOCUMENT_HOLDER);
        if (doc == null) {
            return;
        }
        message.remove(RawMessageWSDLGetInterceptor.DOCUMENT_HOLDER);

        OutputStream out = message.getContent(OutputStream.class);

        String enc = null;
        try {
            enc = doc.getXmlEncoding();
        } catch (Exception ex) {
            //ignore - not dom level 3
        }
        if (enc == null) {
            enc = "utf-8";
        }

        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out, enc);
        try {
            StaxUtils.writeNode(doc, writer, true);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new Fault(e);
        }

    }
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:RawMessageWSDLGetOutInterceptor.java


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


示例19: handleMessage

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
public void handleMessage(Message message) throws Fault {
    DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
    try {
        // put the payload source as a document
        Document doc = StaxUtils.read(xmlReader);
        message.setContent(Source.class, new DOMSource(doc));
    } catch (XMLStreamException e) {
        throw new Fault(new org.apache.cxf.common.i18n.Message("XMLSTREAM_EXCEPTION", JUL_LOG), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:DataInInterceptor.java


示例20: getXMLString

import org.apache.cxf.staxutils.StaxUtils; //导入依赖的package包/类
private static String getXMLString(Element el) {
    try {
        return StaxUtils.toString(el);
    } catch (Throwable t) {
        //ignore
    }
    return "unknown content";
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:DefaultCxfBinding.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UIOutput类代码示例发布时间:2022-05-21
下一篇:
Java TestCore类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap