Document doc = null ;
if (bodyOnlyService) {
// dig out just the body, and pass it with the MessageContext
Vector bodies = reqEnv.getBodyElements();
SOAPBodyElement reqBody = reqEnv.getFirstBody();
NoSuchMethodException exp2 = null ;
doc = reqBody.getAsDOM().getOwnerDocument();
Vector newBodies = new Vector();
for (int i = 0 ; i < bodies.size() ; i++ )
newBodies.add( ((SOAPBodyElement)bodies.get(i)).getAsDOM() );
bodies = newBodies ;
/* If no methodName was specified during deployment then get it */
/* from the root of the Body element */
/* Hmmm, should we do this???? */
/****************************************************************/
if ( methodName == null || methodName.equals("") ) {
Element root = doc.getDocumentElement();
if ( root != null ) methodName = root.getLocalName();
}
// Try the "right" one first, if this fails then default back
// to the old ones - those should be removed eventually.
/////////////////////////////////////////////////////////////////
argClasses = new Class[1];
argObjects = new Object[1];
argClasses[0] = clsLoader.loadClass("java.util.Vector");
argObjects[0] = bodies ;
try {
method = jc.getJavaClass().getMethod( methodName, argClasses );
Element[] result = (Element[]) method.invoke( obj, argObjects );
if ( result != null ) {
for ( int i = 0 ; i < result.length ; i++ )
resEnv.addBodyElement( new SOAPBodyElement(result[i]));
}
return ;
}
catch( NoSuchMethodException exp ) {exp2 = exp;}
if ( method == null ) {
// Try the the simplest case first - just Document as the param
/////////////////////////////////////////////////////////////////
argClasses = new Class[1];
argObjects = new Object[1];
argClasses[0] = clsLoader.loadClass("org.w3c.dom.Document");
argObjects[0] = doc ;
try {
method = jc.getJavaClass().getMethod( methodName, argClasses );
}
catch( NoSuchMethodException exp ) {exp2 = exp;}
}
if ( method == null ) {
String oldmsg = exp2.getMessage();
oldmsg = oldmsg == null ? "" : oldmsg;
String msg = oldmsg + JavaUtils.getMessage("triedClass00",
jc.getJavaClass().getName(), methodName);
throw new NoSuchMethodException(msg);
}
} else {
// pass *just* the MessageContext (maybe don't even parse!!!)
argClasses = new Class[1];
argObjects = new Object[1];
argClasses[0] = clsLoader.loadClass("org.apache.axis.MessageContext");
argObjects[0] = msgContext ;
try {
method = jc.getJavaClass().getMethod( methodName, argClasses );
}
catch( NoSuchMethodException exp2 ) {
// No match - just throw an error
////////////////////////////////////////////
String oldmsg = exp2.getMessage();
oldmsg = oldmsg == null ? "" : oldmsg;
String msg = oldmsg + JavaUtils.getMessage("triedClass00",
jc.getJavaClass().getName(), methodName);
throw new NoSuchMethodException(msg);
}
}
// !!! WANT TO MAKE THIS SAX-CAPABLE AS WELL. Some people will
// want DOM, but our examples should mostly lean towards the
// SAX side of things....
Document retDoc = (Document) method.invoke( obj, argObjects );
if ( retDoc != null ) {
SOAPBodyElement el = new SOAPBodyElement(retDoc.getDocumentElement());
resEnv.addBodyElement(el);
}
}