public static XMLStreamReader createXMLStreamReader(Reader reader) { return createXMLStreamReader(reader, null); }
/** * Writes a HTML description of a service to the given stream. * * @param out the stream to write to * @param service the service * @throws XMLStreamException if an XML writing exception occurs */ public void write(OutputStream out, Service service) throws XMLStreamException { /*XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = factory.createXMLStreamWriter(out);*/ XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, null,null); writer.writeStartDocument(); String title = service.getSimpleName() + " Web Service"; writePreamble(writer, title); writer.writeStartElement("body"); writer.writeStartElement("h1"); writer.writeCharacters(title); writer.writeEndElement(); // h1 writer.writeEndDocument(); writer.flush(); }
public void invoke(MessageContext context) throws Exception { Document doc = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setIgnoringComments(false); dbf.setIgnoringElementContentWhitespace(false); dbf.setNamespaceAware(true); dbf.setCoalescing(false); doc = STAXUtils.read(dbf.newDocumentBuilder(), context.getInMessage().getXMLStreamReader(), false); context.getInMessage().setProperty(DOM_MESSAGE, doc); context.getInMessage().setXMLStreamReader(new W3CDOMStreamReader(doc.getDocumentElement())); } }
boolean clientMode = isClientModeOn(context); while (STAXUtils.toNextElement(dr))
STAXUtils.writeElement(e, xsw, false); for (int i = 0; i < nodes.getLength(); i++) STAXUtils.writeNode(nodes.item(i), xsw, false); STAXUtils.copy(cursor.newXMLStreamReader(), ((ElementWriter) writer).getXMLStreamWriter());
public void writeMessage(OutMessage message, XMLStreamWriter writer, MessageContext context) throws XFireFault { try { STAXUtils.copy(reader, writer); } catch (XMLStreamException e) { XFireFault.createFault(e); } }
public static void writeDocument(Document d, XMLStreamWriter writer, boolean writeProlog, boolean repairing) throws XMLStreamException { if (writeProlog) writer.writeStartDocument(); Element root = d.getDocumentElement(); writeElement(root, writer, repairing); if (writeProlog) writer.writeEndDocument(); }
writeNode(n, writer, repairing);
if (!STAXUtils.toNextElement(dr))
public void writeMessage(OutMessage out, XMLStreamWriter writer, MessageContext ctx) throws XFireFault { try { STAXUtils.copy((XMLStreamReader) out.getBody(), writer); } catch (XMLStreamException e) { throw new XFireFault("Couldn't write to stream.", e, XFireFault.RECEIVER); } } }
public static void writeNode(Node n, XMLStreamWriter writer, boolean repairing) throws XMLStreamException { if ( n instanceof Element ) { writeElement((Element)n, writer, repairing); } else if ( n instanceof Text ) { writer.writeCharacters(((Text) n).getNodeValue()); } else if ( n instanceof CDATASection ) { writer.writeCData(((CDATASection) n).getData()); } else if ( n instanceof Comment ) { writer.writeComment(((Comment) n).getData()); } else if ( n instanceof EntityReference ) { writer.writeEntityRef(((EntityReference)n).getNodeValue()); } else if ( n instanceof ProcessingInstruction ) { ProcessingInstruction pi = (ProcessingInstruction) n; writer.writeProcessingInstruction(pi.getTarget(), pi.getData()); } }
/** * Constructor * Description: Get the Set of Resources, and the xml string that is a wrapper around the whole Resource set. * @param resSet Set of XML Resource objects * @param xmlWrapper XML string used to wrap the ResourceSet hence it elements at the beginning and end. */ public ResourceStreamDelegate(List resSet,String xmlWrapper) { super(); this.resSet = resSet; //create a StreamReader for the xml string wrapper. And since this is in the beginning set it as the current parent. wrapperStreamReader = STAXUtils.createXMLStreamReader(new StringReader(xmlWrapper)); setParent(wrapperStreamReader); }
/** * Reads a message. Because this is a server-side message binding, the messages we will be *reading* * are request messages. Therefore, this method finds the operation whose input message name matches * the name of the request element, sets that operation in the context, looks up the binding for that * operation, and delegates the rest of the read to the binding. * * @param message The message to read. * @param context The context. * @see org.codehaus.xfire.jaxws.JAXWSBinding */ public void readMessage(InMessage message, MessageContext context) throws XFireFault { Service endpoint = context.getService(); DepthXMLStreamReader dr = new DepthXMLStreamReader(message.getXMLStreamReader()); if (!STAXUtils.toNextElement(dr)) { throw new XFireFault("There must be a method name element.", XFireFault.SENDER); } QName messageName = dr.getName(); OperationInfo opInfo = findOperation(endpoint, messageName); if (opInfo == null) { throw new XFireFault("Unknown operation: " + messageName, XFireFault.SENDER); } context.getExchange().setOperation(opInfo); EnunciatedJAXWSOperationBinding binding = op2Binding.get(opInfo); if (binding == null) { binding = new EnunciatedJAXWSOperationBinding(opInfo); op2Binding.put(opInfo, binding); } binding.readMessage(message, context); }
private String getMessageAsString(MessageContext context, OutMessage message) throws XFireFault { ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, message.getEncoding(), context); message.getSerializer().writeMessage(message, writer, context); try { writer.flush(); writer.close(); out.close(); } catch (Exception e) { log.error("Error serializing message", e); } return out.toString(); }
Document inputDoc = STAXUtils.read(builder,reader,true); String inputURI = inputDoc.getDocumentElement().getNamespaceURI(); IAdmin admin;
STAXUtils.copy(xsr, writer); xsr.close();
/** * Constructor * Description: Get the Set of Resources, and the xml string that is a wrapper around the whole Resource set. * @param resSet Set of XML Resource objects * @param xmlWrapper XML string used to wrap the ResourceSet hence it elements at the beginning and end. */ public RegistryXMLStreamDelegate(ResourceSet resSet,String xmlWrapper) { super(); this.resSet = resSet; //create a StreamReader for the xml string wrapper. And since this is in the beginning set it as the current parent. wrapperStreamReader = STAXUtils.createXMLStreamReader(new StringReader(xmlWrapper)); setParent(wrapperStreamReader); }
/** * Reads a message. Because this is a server-side message binding, the messages we will be *reading* * are request messages. Therefore, this method finds the operation whose input message name matches * the name of the request element, sets that operation in the context, looks up the binding for that * operation, and delegates the rest of the read to the binding. * * @param message The message to read. * @param context The context. * @see org.codehaus.xfire.jaxws.JAXWSBinding */ public void readMessage(InMessage message, MessageContext context) throws XFireFault { Service endpoint = context.getService(); DepthXMLStreamReader dr = new DepthXMLStreamReader(message.getXMLStreamReader()); if (!STAXUtils.toNextElement(dr)) { throw new XFireFault("There must be a method name element.", XFireFault.SENDER); } QName messageName = dr.getName(); OperationInfo opInfo = findOperation(endpoint, messageName); if (opInfo == null) { throw new XFireFault("Unknown operation: " + messageName, XFireFault.SENDER); } context.getExchange().setOperation(opInfo); EnunciatedJAXWSOperationBinding binding = op2Binding.get(opInfo); if (binding == null) { binding = new EnunciatedJAXWSOperationBinding(opInfo); op2Binding.put(opInfo, binding); } binding.readMessage(message, context); }
public static void writeWithoutAttachments(MessageContext context, OutMessage message, OutputStream out) throws XFireException { XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, message.getEncoding(), context); message.getSerializer().writeMessage(message, writer, context); try { writer.flush(); } catch (XMLStreamException e) { log.error(e); throw new XFireException("Couldn't send message.", e); } }
Document inputDoc = STAXUtils.read(builder,reader,true);