}
MessageElement curEl = context.getCurElement();
QName type = null;
QName qname = new QName(namespace, localName);
ParameterDesc paramDesc = null;
Vector params = rpcElem.getParams();
// SAR: for now, ignore RPC Result elements
if (qname.equals(Constants.QNAME_RPC_RESULT)) return this;
// Create a new param if not the same element
if (currentParam == null ||
!currentParam.getQName().getNamespaceURI().equals(namespace) ||
!currentParam.getQName().getLocalPart().equals(localName)) {
currentParam = new RPCParam(namespace, localName, null);
rpcElem.addParam(currentParam);
}
// Grab xsi:type attribute if present, on either this element or
// the referent (if it's an href). MessageElement.getType() will
// automatically dig through to the referent if necessary.
type = curEl.getType();
if (type == null) {
type = context.getTypeFromAttributes(namespace,
localName,
attributes);
}
if (log.isDebugEnabled()) {
log.debug(JavaUtils.getMessage("typeFromAttr00", "" + type));
}
Class destClass = null;
// If we have an operation descriptor, try to associate this parameter
// with the appropriate ParameterDesc
if (operation != null) {
// Try by name first
if (isResponse) {
paramDesc = operation.getOutputParamByQName(qname);
} else {
paramDesc = operation.getInputParamByQName(qname);
}
// If that didn't work, try position
// FIXME : Do we need to be in EITHER named OR positional
// mode? I.e. will it screw us up to find something
// by position if we've already looked something up
// by name? I think so...
if (paramDesc == null) {
paramDesc = operation.getParameter(params.size() - 1);
}
if (paramDesc == null) {
throw new SAXException("operation description is missing parameter description!");
}
destClass = paramDesc.getJavaType();
// Keep the association so we can use it later
// (see RPCProvider.processMessage())
currentParam.setParamDesc(paramDesc);
if (type == null) {
type = paramDesc.getTypeQName();
}
}
// If the nil attribute is set, just
// return the base DeserializerImpl.
// Register the value target to set the value
// on the RPCParam. This is necessary for cases like
// <method>
// <foo>123</foo>
// <foo>456</foo>
// <foo xsi:nil="true" />
// </method>
// so that a list of 3 items is created.
// Failure to register the target would result in the last
// item not being added to the list
if (context.isNil(attributes)) {
Deserializer nilDSer = new DeserializerImpl();
nilDSer.registerValueTarget(
new MethodTarget(currentParam,
RPCParam.getValueSetMethod()));
return (SOAPHandler) nilDSer;
}
Deserializer dser = null;
if ((type == null) && (namespace != null) && (!namespace.equals(""))) {
dser = context.getDeserializerForType(qname);
} else {
dser = context.getDeserializer(destClass, type);
}
if (dser == null) {
if (type != null) {
dser = context.getDeserializerForType(type);
if (dser == null) {
throw new SAXException(JavaUtils.getMessage(
"noDeser01", localName,"" + type));
}
if (paramDesc != null && paramDesc.getJavaType() != null) {
// If we have an xsi:type, make sure it makes sense
// with the current paramDesc type
Class xsiClass =
context.getTypeMapping().getClassForQName(type);
if (!JavaUtils.isConvertable(xsiClass, destClass)) {