{
schema = currentSchema;
}
}
OMNamespace omNamespace = null;
if (isQualified(schema))
{
final String namespace = Axis2ClientUtils.getTargetNamespace(schema);
final String namespacePrefix = getNamespacePrefix(
definition,
namespace);
omNamespace = namespaces.get(namespacePrefix);
}
final OMElement omElement =
factory.createOMElement(
elementName,
omNamespace);
if (bean != null && evaluatingBeans != null && !evaluatingBeans.contains(bean))
{
evaluatingBeans.add(bean);
if (isSimpleType(bean, typeMapper))
{
omElement.addChild(factory.createOMText(typeMapper.getStringValue(bean)));
}
else if (bean instanceof byte[])
{
omElement.addChild(factory.createOMText(Base64.encode((byte[])bean)));
}
else
{
final Element currentComponentElement =
Axis2ClientUtils.getElementByAttribute(
definition,
NAME,
bean.getClass().getSimpleName());
final Class beanType = bean.getClass();
if (beanType.isArray())
{
final Element arrayElement = Axis2ClientUtils.getRequiredElementByAttribute(
definition,
componentElement,
NAME,
elementName);
final Element arrayTypeElement =
Axis2ClientUtils.getElementByAttribute(
definition,
NAME,
stripPrefix(arrayElement.getAttribute(TYPE)));
final String arrayComponentName = Axis2ClientUtils.getAttributeValueFromChildElement(
arrayTypeElement,
NAME,
0);
for (int ctr = 0; ctr < Array.getLength(bean); ctr++)
{
omElement.addChild(
getOMElement(
definition,
schema,
currentComponentElement,
Array.get(
bean,
ctr),
arrayComponentName,
factory,
namespaces,
typeMapper,
evaluatingBeans));
}
}
else
{
final String attributeValue = omNamespace != null ?
omNamespace.getPrefix() + NS_SEPARATOR + beanType.getSimpleName() : beanType.getSimpleName();
// - add the xsi:type attribute for complex types
omElement.addAttribute(TYPE, attributeValue, namespaces.get(XSI_PREFIX));
}
try
{