log.debug("Enter: RPCProvider.processMessage()");
}
SOAPService service = msgContext.getService();
ServiceDesc serviceDesc = service.getServiceDescription();
OperationDesc operation = msgContext.getOperation();
Vector bodies = reqEnv.getBodyElements();
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage("bodyElems00", "" + bodies.size()));
log.debug(Messages.getMessage("bodyIs00", "" + bodies.get(0)));
}
RPCElement body = null;
// Find the first "root" body element, which is the RPC call.
for ( int bNum = 0 ; body == null && bNum < bodies.size() ; bNum++ ) {
// If this is a regular old SOAPBodyElement, and it's a root,
// we're probably a non-wrapped doc/lit service. In this case,
// we deserialize the element, and create an RPCElement "wrapper"
// around it which points to the correct method.
// FIXME : There should be a cleaner way to do this...
if (!(bodies.get(bNum) instanceof RPCElement)) {
SOAPBodyElement bodyEl = (SOAPBodyElement)bodies.get(bNum);
// igors: better check if bodyEl.getID() != null
// to make sure this loop does not step on SOAP-ENC objects
// that follow the parameters! FIXME?
if (bodyEl.isRoot() && operation != null && bodyEl.getID() == null) {
ParameterDesc param = operation.getParameter(bNum);
// at least do not step on non-existent parameters!
if(param != null) {
Object val = bodyEl.getValueAsType(param.getTypeQName());
body = new RPCElement("",
operation.getName(),
new Object [] { val });
}
}
} else {
body = (RPCElement) bodies.get( bNum );
}
}
// special case code for a document style operation with no
// arguments (which is a strange thing to have, but whatever)
if (body == null) {
// throw an error if this isn't a document style service
if (!serviceDesc.getStyle().equals(Style.DOCUMENT)) {
throw new Exception(Messages.getMessage("noBody00"));
}
// look for a method in the service that has no arguments,
// use the first one we find.
ArrayList ops = serviceDesc.getOperations();
for (Iterator iterator = ops.iterator(); iterator.hasNext();) {
OperationDesc desc = (OperationDesc) iterator.next();
if (desc.getNumInParams() == 0) {
// found one with no parameters, use it
msgContext.setOperation(desc);
// create an empty element
body = new RPCElement(desc.getName());
// stop looking
break;
}
}