*/
public void marshall(Class parent, QName qname, ExtensibilityElement obj, PrintWriter pw,
final Definition wsdl, ExtensionRegistry registry) throws WSDLException {
// TODO Auto-generated method stub
try {
Marshaller u = context.createMarshaller();
u.setProperty("jaxb.encoding", "UTF-8");
u.setProperty("jaxb.fragment", Boolean.TRUE);
u.setProperty("jaxb.formatted.output", Boolean.TRUE);
Object mObj = obj;
Class<?> objectFactory = Class.forName(typeClass.getPackage().getName() + ".ObjectFactory");
Method methods[] = objectFactory.getDeclaredMethods();
for (Method method : methods) {
if (method.getParameterTypes().length == 1
&& method.getParameterTypes()[0].equals(typeClass)) {
mObj = method.invoke(objectFactory.newInstance(), new Object[] {obj});
}
}
javax.xml.stream.XMLOutputFactory fact = javax.xml.stream.XMLOutputFactory.newInstance();
XMLStreamWriter writer = fact.createXMLStreamWriter(pw);
writer.setNamespaceContext(new javax.xml.namespace.NamespaceContext() {
public String getNamespaceURI(String arg) {
return wsdl.getNamespace(arg);
}
public String getPrefix(String arg) {
for (Object ent : wsdl.getNamespaces().entrySet()) {
Map.Entry entry = (Map.Entry)ent;
if (arg.equals(entry.getValue())) {
return (String)entry.getKey();
}
}
return null;
}
public Iterator getPrefixes(String arg) {
return wsdl.getNamespaces().keySet().iterator();
}
});
u.marshal(mObj, writer);
writer.flush();
} catch (Exception ex) {
throw new WSDLException(WSDLException.PARSER_ERROR,
"",
ex);