### Question:
SerializationUtils { public static void serializeSingleNamespaceNVOutput(String namespaceURL, Object obj, OutputStream os) throws XMLStreamException, JAXBException { NamespaceConvention nsConv = NamespaceConvention.createSingleNamespaceSerializationConvention("ns1", namespaceURL); String rooJavaName = obj.getClass().getSimpleName(); QName rootXmlName = new QName(namespaceURL, rooJavaName); NVStreamWriter sw = new NVStreamWriter(nsConv, rootXmlName, os); Class rootClass = obj.getClass(); JAXBContext jCtxt = JAXBContextBuilder.createJAXBContextForSerialization(rootClass); @SuppressWarnings("unchecked") JAXBElement jaxbElement = new JAXBElement(rootXmlName, rootClass, obj); Marshaller m = jCtxt.createMarshaller(); m.marshal(jaxbElement, sw); }  static void serializeSingleNamespaceJSONOutput(String namespaceURL, Object obj, OutputStream os); static void serializeSingleNamespaceNVOutput(String namespaceURL, Object obj, OutputStream os);  }### Answer:
@Test public void jaxbNVSimpleSerialization() throws Exception { MyMessage msg = createTestMessage(1); ByteArrayOutputStream baos = new ByteArrayOutputStream(); SerializationUtils.serializeSingleNamespaceNVOutput(TEST_NAMESPACE_URL, msg, baos); String result = baos.toString("UTF-8"); System.out.println(result); StringBuilder nv = new StringBuilder(); nv.append("body(0)=\"SOA+in+Chinese+is+%27"); nv.append(SOA_IN_CHINESE_STRING_URL_ENCODED); nv.append("%27\""); nv.append("&recipients(0).entry(0).key(0)=\"soa0%40ebayopensource.org\""); nv.append("&recipients(0).entry(0).value(0).city(0)=\"San+Jose\""); nv.append("&recipients(0).entry(0).value(0).emailAddress(0)"); nv.append("=\"soa0%40ebayopensource.org\""); nv.append("&recipients(0).entry(0).value(0).postCode(0)=\"95125\""); nv.append("&recipients(0).entry(0).value(0).state(0)=\"CA\""); nv.append("&recipients(0).entry(0).value(0).streetNumber(0)=\"2000\""); nv.append("&something(0).xsi:@type=\"xs%3Astring\""); nv.append("&something(0)=\"This+is+from+the+any+object+type\""); nv.append("&subject(0)=\"SOA+Framework+test+message\""); assertEquals(nv.toString(), result); }