* <p>
*/
public void invoke(MessageContext ctx) throws AxisFault {
//XMLDispatcherClient xd = this.getXMLDispatcherClient();
ClassInfoCache classInfoCache = new ClassInfoCache(this.xd);
RPCElement body = null;
// initialize some variables
SOAPEnvelope reqEnv = ctx.getRequestMessage().getSOAPEnvelope();
ServiceDesc serviceDesc = ctx.getService().getServiceDescription();
// find the first 'root' body element, which is the RPC call
Vector bodies = reqEnv.getBodyElements();
for (int i = 0; body == null && i < bodies.size(); i++) {
if (bodies.get(i) instanceof RPCElement) {
body = (RPCElement) bodies.get(i);
}
}
// if we didn't find anything, throw an exception
if (body == null) {
throw new AxisFault("No RPCElement found in SOAP message");
}
//extract the xmlstruct message
String rqst = null;
String instanceId = null;
String sessionData = null;
String webServiceNs = body.getNamespaceURI();
for (Iterator iter = body.getChildElements(); iter.hasNext();) {
MessageElement msg = (MessageElement) iter.next();
// TODO what if xmlns is null?
if (msg.getLocalName().equals("instanceId") && msg.getNamespaceURI().equals(webServiceNs)) {
// TODO what if no child elements
instanceId = ((Text) msg.getChildElements().next()).getData();
continue;
}
else if (msg.getName().equals("sessionData") && msg.getNamespaceURI().equals(webServiceNs)) {
// TODO what if no child elements
sessionData = ((Text) msg.getChildElements().next()).getData();
continue;
}
else {
if (rqst == null) {
rqst = msg.toString();
}
else {
//TODO error because more than one "struct" element
throw new AxisFault("error because more than one struct element");
}
}
}
// looks ok, get name of invoked operation on service
String className = body.getMethodName().split("-")[0];
String methodName = body.getMethodName().split("-")[1];
String rply = null;
short verb;
try {
verb = classInfoCache.getVerb(className, methodName);
// if instanceId != null -> instanceMethod
// else need to call getClassInfo to distinguish between classMethod and newInstanceMethod
// EnvelopeConstants.verbDispatchClassMethodXML
// classInfoRply = dispatchClassMethodXML(className,"getClassInfo",null,null);