List of usage examples for javax.xml.namespace QName QName
public QName(String localPart)
QName
constructor specifying the local part.
If the local part is null
an IllegalArgumentException
is thrown.
From source file:org.apache.servicemix.quartz.QuartzComponentTest.java
public void test() throws Exception { JBIContainer jbi = new JBIContainer(); jbi.setEmbedded(true);// w w w .ja v a 2s . c o m jbi.init(); QuartzComponent quartz = new QuartzComponent(); QuartzEndpoint endpoint = new QuartzEndpoint(); endpoint.setService(new QName("quartz")); endpoint.setEndpoint("endpoint"); endpoint.setTargetService(new QName("countDownReceiver")); SimpleTriggerBean trigger = new SimpleTriggerBean(); trigger.setRepeatInterval(100); trigger.setName("trigger"); trigger.afterPropertiesSet(); endpoint.setTrigger(trigger); quartz.setEndpoints(new QuartzEndpoint[] { endpoint }); jbi.activateComponent(quartz, "servicemix-quartz"); CountDownReceiverComponent receiver = new CountDownReceiverComponent(new QName("countDownReceiver"), "endpoint", 1, 3000); jbi.activateComponent(receiver, "countDownReceiver"); jbi.start(); assertTrue(receiver.getMessageList().flushMessages().size() > 0); quartz.stop(); receiver.getMessageList().flushMessages(); Thread.sleep(1000); assertEquals(0, receiver.getMessageList().flushMessages().size()); quartz.start(); receiver.reset(); assertTrue(receiver.getMessageList().flushMessages().size() > 0); jbi.shutDown(); }
From source file:net.bpelunit.framework.control.deploy.activebpel.BPRDeployRequestEntity.java
@Override protected void populateMessage(SOAPMessage message) throws SOAPException, IOException { SOAPElement xmlDeployBpr = addRootElement(message, new QName(ACTIVEBPEL_ELEMENT_DEPLOYBPR)); // Add filename SOAPElement xmlBprFilename = xmlDeployBpr.addChildElement(ACTIVEBPEL_ELEMENT_ABPRFILENAME); xmlBprFilename.addAttribute(new QName(ActiveBPELRequestEntityBase.NS_XMLSCHEMA_INSTANCE, "type"), XSD_STRING);/*from w ww .j av a2 s.c o m*/ xmlBprFilename.setTextContent(FilenameUtils.getName(file.toString())); // Add data SOAPElement xmlBase64File = xmlDeployBpr.addChildElement(ACTIVEBPEL_ELEMENT_ABASE64FILE); xmlBase64File.addAttribute(new QName(ActiveBPELRequestEntityBase.NS_XMLSCHEMA_INSTANCE, "type"), XSD_STRING); StringBuilder content = new StringBuilder(); byte[] arr = FileUtils.readFileToByteArray(file); byte[] encoded = Base64.encodeBase64Chunked(arr); for (int i = 0; i < encoded.length; i++) { content.append((char) encoded[i]); } xmlBase64File.setTextContent(content.toString()); }
From source file:at.ac.univie.isc.asio.tool.ExpandingQNameSerializerTest.java
@Test public void should_write_local_only_qname_as_is() throws Exception { subject.serialize(new QName("local-only"), generator, null); generator.flush();//ww w . j av a 2 s . c o m assertThat(sink.toString(), is("\"local-only\"")); }
From source file:controller.JaxbUtil.java
@SuppressWarnings("unchecked") public String toXml(Collection root, String rootName, String encoding) { try {/*from w w w . j av a 2 s. c om*/ CollectionWrapper wrapper = new CollectionWrapper(); wrapper.collection = root; JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName), CollectionWrapper.class, wrapper); StringWriter writer = new StringWriter(); createMarshaller(encoding).marshal(wrapperElement, writer); return writer.toString(); } catch (JAXBException ex) { throw new RuntimeException(ex); } }
From source file:com.common.util.mapper.JaxbMapper.java
/** * Java Collection->Xml with encoding, ?Root ElementCollection. *///from www. j a v a2 s .c o m public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.collection = root; JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName), CollectionWrapper.class, wrapper); StringWriter writer = new StringWriter(); try { createMarshaller(clazz, encoding).marshal(wrapperElement, writer); } catch (JAXBException e) { e.printStackTrace(); } return writer.toString(); }
From source file:com.plateform.common.util.JaxbMapper.java
/** * Java Collection->Xml with encoding, ?Root ElementCollection. *//* w w w. j a v a 2 s. c o m*/ public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) { try { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.collection = root; JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName), CollectionWrapper.class, wrapper); StringWriter writer = new StringWriter(); createMarshaller(clazz, encoding).marshal(wrapperElement, writer); return writer.toString(); } catch (JAXBException e) { throw ExceptionUtils.unchecked(e); } }
From source file:com.androidwhy.modules.mapper.JaxbMapper.java
/** * Java Collection->Xml with encoding, ?Root ElementCollection. *//*from w w w. j a va 2 s. c o m*/ public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) { try { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.collection = root; JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName), CollectionWrapper.class, wrapper); StringWriter writer = new StringWriter(); createMarshaller(clazz, encoding).marshal(wrapperElement, writer); return writer.toString(); } catch (JAXBException e) { throw Exceptions.unchecked(e); } }
From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.AttachmentUtils.java
public static boolean prepareRequestPart(WsdlRequest wsdlRequest, MimeMultipart mp, RequestXmlPart requestPart, StringToStringMap contentIds) throws Exception, MessagingException { boolean isXop = false; XmlCursor cursor = requestPart.newCursor(); try {//from www .j ava2s . c o m while (!cursor.isEnddoc()) { if (cursor.isContainer()) { // could be an attachment part (as of "old" SwA specs which specify a content // element referring to the attachment) if (requestPart.isAttachmentPart()) { String href = cursor.getAttributeText(new QName("href")); if (href != null && href.length() > 0) { contentIds.put(requestPart.getPart().getName(), href); } break; } SchemaType schemaType = cursor.getObject().schemaType(); if (isBinaryType(schemaType)) { String contentType = getXmlMimeContentType(cursor); // extract contentId String textContent = cursor.getTextValue(); Attachment attachment = null; boolean isXopAttachment = false; // is content a reference to a file? if (textContent.startsWith("file:")) { String filename = textContent.substring(5); if (contentType == null) { inlineData(cursor, schemaType, new FileInputStream(filename)); } else if (wsdlRequest.isMtomEnabled()) { MimeBodyPart part = new PreencodedMimeBodyPart("binary"); part.setDataHandler(new DataHandler( new XOPPartDataSource(new File(filename), contentType, schemaType))); part.setContentID("<" + filename + ">"); mp.addBodyPart(part); isXopAttachment = true; } } // is content a reference to an attachment? else if (textContent.startsWith("cid:")) { textContent = textContent.substring(4); Attachment[] attachments = wsdlRequest.getAttachmentsForPart(textContent); if (attachments.length == 1) { attachment = attachments[0]; } else if (attachments.length > 1) { attachment = buildMulitpartAttachment(attachments); } isXopAttachment = contentType != null; contentIds.put(textContent, textContent); } // content should be binary data; is this an XOP element which should be serialized with MTOM? else if (wsdlRequest.isMtomEnabled() && contentType != null) { MimeBodyPart part = new PreencodedMimeBodyPart("binary"); part.setDataHandler( new DataHandler(new XOPPartDataSource(textContent, contentType, schemaType))); textContent = "http://www.soapui.org/" + System.nanoTime(); part.setContentID("<" + textContent + ">"); mp.addBodyPart(part); isXopAttachment = true; } // add XOP include? if (isXopAttachment && wsdlRequest.isMtomEnabled()) { buildXopInclude(cursor, textContent); isXop = true; } // inline? else if (attachment != null) { inlineAttachment(cursor, schemaType, attachment); } } } cursor.toNextToken(); } } finally { cursor.dispose(); } return isXop; }
From source file:com.topsem.common.mapper.JaxbMapper.java
/** * Java Collection->Xml with encoding, ?Root ElementCollection. */// w w w . j a v a 2s.c om public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) { try { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.collection = root; JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName), CollectionWrapper.class, wrapper); StringWriter writer = new StringWriter(); createMarshaller(clazz, encoding).marshal(wrapperElement, writer); return writer.toString(); } catch (JAXBException e) { throw Throwables.propagate(e); } }
From source file:com.wsun.seap.common.mapper.JaxbMapper.java
/** * Java Collection->Xml with encoding, ?Root ElementCollection. *//*from w w w . j a va 2s .c om*/ public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding) { try { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.collection = root; JAXBElement<CollectionWrapper> wrapperElement = new JAXBElement<CollectionWrapper>(new QName(rootName), CollectionWrapper.class, wrapper); StringWriter writer = new StringWriter(); createMarshaller(clazz, encoding).marshal(wrapperElement, writer); return writer.toString(); } catch (JAXBException e) { throw ExceptionUtil.unchecked(e); } }