}
if (serviceRef.getValue() != null) {
Object value = serviceRef.getValue();
if (value instanceof ExtensibilityElement) {
ExtensibilityElement extensibilityElement = (ExtensibilityElement)value;
BPELExtensionSerializer serializer = null;
QName qname = extensibilityElement.getElementType();
try {
serializer=(BPELExtensionSerializer)extensionRegistry.querySerializer(ExtensibleElement.class,qname);
} catch (WSDLException e) {
}
if (serializer != null) {
// Deserialize the DOM element and add the new Extensibility element to the parent
// ExtensibleElement
DocumentFragment fragment=document.createDocumentFragment();
try {
serializer.marshall(ExtensibleElement.class,qname,extensibilityElement,fragment,process,extensionRegistry);
Element child = (Element)fragment.getFirstChild();
serviceRefElement.appendChild(child);
} catch (WSDLException e) {
throw new WrappedException(e);
}
}
} else {
ServiceReferenceSerializer serializer = extensionRegistry.getServiceReferenceSerializer(referenceScheme);
if (serializer != null) {
DocumentFragment fragment=document.createDocumentFragment();
serializer.marshall(value, fragment, process, from, this);
Element child = (Element)fragment.getFirstChild();
serviceRefElement.appendChild(child);
} else {
CDATASection cdata = BPELUtils.createCDATASection(document, serviceRef.getValue().toString());
serviceRefElement.appendChild(cdata);