try {
writer.writeStartElement(MEX_PREFIX,
"MetadataSection", MEX_NAMESPACE);
if (doc.isWSDL()) {
writer.writeAttribute("Dialect", WSDL_DIALECT);
writer.writeAttribute("Identifier",
((SDDocument.WSDL) doc).getTargetNamespace());
} else if(doc.isSchema()) {
writer.writeAttribute("Dialect", SCHEMA_DIALECT);
writer.writeAttribute("Identifier",
((SDDocument.Schema) doc).getTargetNamespace());
}
doc.writeTo(new PortAddressResolverImpl(add), dar, writer);
writer.writeEndElement();
} catch (IOException ioe) {
// this should be very rare
String exceptionMessage =
MessagesMessages.MEX_0015_IOEXCEPTION_WHILE_WRITING_RESPONSE(add);
logger.log(Level.SEVERE, exceptionMessage, ioe);
throw new WebServiceException(exceptionMessage, ioe);
}