@Test public void testSerializeRpc_out() throws Exception { Optional<RpcDefinition> loadRpc = ConverterUtils.loadRpc(schemaContext, SIMPLE_IO_RPC_QNAME); Writer serializeRpc = bindingSerializer.serializeRpc(loadRpc.get().getOutput(), testedSimpleRpcOutputNormalizedNodes); Assert.assertFalse(Strings.isNullOrEmpty(serializeRpc.toString())); LOG.info(serializeRpc.toString()); }
@Override public Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); XMLStreamWriter xmlStreamWriter = createXmlStreamWriter(writer); URI namespace = schemaNode.getQName().getNamespace(); String localName = schemaNode.getQName().getLocalName(); try (NormalizedNodeWriter normalizedNodeWriter = createNormalizedNodeWriter(schemaContext, xmlStreamWriter, schemaNode.getPath())) { xmlStreamWriter.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, localName, namespace.toString()); xmlStreamWriter.writeDefaultNamespace(namespace.toString()); for (NormalizedNode<?, ?> child : ((ContainerNode) normalizedNode).getValue()) { normalizedNodeWriter.write(child); } normalizedNodeWriter.flush(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.flush(); } catch (IOException | XMLStreamException ioe) { throw new SerializationException(ioe); } return writer; }
XmlNodeConverter implements NodeConverter { @Override public Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); XMLStreamWriter xmlStreamWriter = createXmlStreamWriter(writer); URI namespace = schemaNode.getQName().getNamespace(); String localName = schemaNode.getQName().getLocalName(); try (NormalizedNodeWriter normalizedNodeWriter = createNormalizedNodeWriter(schemaContext, xmlStreamWriter, schemaNode.getPath())) { xmlStreamWriter.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, localName, namespace.toString()); xmlStreamWriter.writeDefaultNamespace(namespace.toString()); for (NormalizedNode<?, ?> child : ((ContainerNode) normalizedNode).getValue()) { normalizedNodeWriter.write(child); } normalizedNodeWriter.flush(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.flush(); } catch (IOException | XMLStreamException ioe) { throw new SerializationException(ioe); } return writer; } }
XmlNodeConverter implements NodeConverter { @Override public Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); XMLStreamWriter xmlStreamWriter = createXmlStreamWriter(writer); URI namespace = schemaNode.getQName().getNamespace(); String localName = schemaNode.getQName().getLocalName(); try (NormalizedNodeWriter normalizedNodeWriter = createNormalizedNodeWriter(schemaContext, xmlStreamWriter, schemaNode.getPath())) { xmlStreamWriter.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, localName, namespace.toString()); xmlStreamWriter.writeDefaultNamespace(namespace.toString()); for (NormalizedNode<?, ?> child : ((ContainerNode) normalizedNode).getValue()) { normalizedNodeWriter.write(child); } normalizedNodeWriter.flush(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.flush(); } catch (IOException | XMLStreamException ioe) { throw new SerializationException(ioe); } return writer; } XmlNodeConverter(final SchemaContext schemaContext); }
XmlNodeConverter implements NodeConverter { @Override public Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); XMLStreamWriter xmlStreamWriter = createXmlStreamWriter(writer); URI namespace = schemaNode.getQName().getNamespace(); String localName = schemaNode.getQName().getLocalName(); try (NormalizedNodeWriter normalizedNodeWriter = createNormalizedNodeWriter(schemaContext, xmlStreamWriter, schemaNode.getPath())) { xmlStreamWriter.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, localName, namespace.toString()); xmlStreamWriter.writeDefaultNamespace(namespace.toString()); for (NormalizedNode<?, ?> child : ((ContainerNode) normalizedNode).getValue()) { normalizedNodeWriter.write(child); } normalizedNodeWriter.flush(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.flush(); } catch (IOException | XMLStreamException ioe) { throw new SerializationException(ioe); } return writer; } XmlNodeConverter(final SchemaContext schemaContext); @Override Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override NormalizedNode<?, ?> deserialize(final SchemaNode schemaNode, final Reader inputData); static void closeQuietly(final XMLStreamReader xmlStreamReader); }
XmlNodeConverter implements NodeConverter { @Override public Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode) throws SerializationException { Writer writer = new StringWriter(); XMLStreamWriter xmlStreamWriter = createXmlStreamWriter(writer); URI namespace = schemaNode.getQName().getNamespace(); String localName = schemaNode.getQName().getLocalName(); try (NormalizedNodeWriter normalizedNodeWriter = createNormalizedNodeWriter(schemaContext, xmlStreamWriter, schemaNode.getPath())) { xmlStreamWriter.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, localName, namespace.toString()); xmlStreamWriter.writeDefaultNamespace(namespace.toString()); for (NormalizedNode<?, ?> child : ((ContainerNode) normalizedNode).getValue()) { normalizedNodeWriter.write(child); } normalizedNodeWriter.flush(); xmlStreamWriter.writeEndElement(); xmlStreamWriter.flush(); } catch (IOException | XMLStreamException ioe) { throw new SerializationException(ioe); } return writer; } XmlNodeConverter(final SchemaContext schemaContext); @Override Writer serializeData(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override Writer serializeRpc(final SchemaNode schemaNode, final NormalizedNode<?, ?> normalizedNode); @Override NormalizedNode<?, ?> deserialize(final SchemaNode schemaNode, final Reader inputData); static void closeQuietly(final XMLStreamReader xmlStreamReader);  }