final Method method,
final Object[] arguments,
final TypeMapper typeMapper)
{
final Class serviceClass = method.getDeclaringClass();
OMElement operationOMElement = null;
try
{
final String operationName = method.getName();
final String serviceName = serviceClass.getSimpleName();
final Element operationElement = getElementByAttribute(
definition,
NAME,
operationName);
final Schema operationSchema = Axis2ClientUtils.getElementSchemaByAttribute(
definition,
NAME,
operationName);
if (operationSchema != null)
{
final OMFactory factory = OMAbstractFactory.getOMFactory();
// - collect all the namespaces
final Map<String, OMNamespace> namespaces = new HashMap<String, OMNamespace>();
final OMNamespace xsiNamespace = factory.createOMNamespace(XSI_NS, XSI_PREFIX);
namespaces.put(XSI_PREFIX, xsiNamespace);
final Collection<Schema> schemas = getSchemas(definition);
for (final Schema schema : schemas)
{
final String namespace = Axis2ClientUtils.getTargetNamespace(schema);
final String prefix = getNamespacePrefix(
definition,
namespace);
namespaces.put(prefix, factory.createOMNamespace(namespace, prefix));
}
operationOMElement =
getOMElement(
definition,
operationSchema,
null,
null,
operationName,
factory,
namespaces,
typeMapper);
if (operationElement == null)
{
throw new RuntimeException("No operation with name '" + operationName + "' can be found on service: " +
serviceName);
}
final List argumentElements = Axis2ClientUtils.getElementsWithAttribute(
operationElement,
TYPE);
final Class[] parameterTypes = method.getParameterTypes();
if (argumentElements.size() != arguments.length)
{
throw new RuntimeException("Operation: " + operationName + " takes " + parameterTypes.length +
" argument(s), and 'arguments' only contains: " + arguments.length);
}
// - declare all the namespaces
operationOMElement.declareNamespace(xsiNamespace);
for (final OMNamespace namespace : namespaces.values())
{
operationOMElement.declareNamespace(namespace);
}
// - add the argument children
for (int ctr = 0; ctr < argumentElements.size(); ctr++)
{
final Element argument = (Element)argumentElements.get(ctr);
final String argumentName = getAttributeValue(
argument,
NAME);
final OMElement element = getOMElement(
definition,
operationSchema,
argument,
arguments[ctr],
argumentName,