public void deserialize() throws SAXException
{
needDeser = false;
MessageContext msgContext = context.getMessageContext();
// Figure out if we should be looking for out params or in params
// (i.e. is this message a response?)
Message msg = msgContext.getCurrentMessage();
boolean isResponse = ((msg != null) &&
Message.RESPONSE.equals(msg.getMessageType()));
// We're going to need this below, so create one.
RPCHandler rpcHandler = new RPCHandler(this, isResponse);
if (operations != null) {
int numParams = (getChildren() == null) ? 0 : getChildren().size();
SAXException savedException = null;
// We now have an array of all operations by this name. Try to
// find the right one. For each matching operation which has an
// equal number of "in" parameters, try deserializing. If we
// don't succeed for any of the candidates, punt.
for (int i = 0; i < operations.length; i++) {
OperationDesc operation = operations[i];
// See if any information is coming from a header
boolean needHeaderProcessing =
needHeaderProcessing(operation, isResponse);
// Make a quick check to determine if the operation
// could be a match.
// 1) The element is the first param, DOCUMENT, (i.e.
// don't know the operation name or the number
// of params, so try all operations).
// or (2) Style is literal
// If the Style is LITERAL, the numParams may be inflated
// as in the following case:
// <getAttractions xmlns="urn:CityBBB">
// <attname>Christmas</attname>
// <attname>Xmas</attname>
// </getAttractions>
// for getAttractions(String[] attName)
// numParams will be 2 and and operation.getNumInParams=1
// or (3) Number of expected params is
// >= num params in message
if (operation.getStyle() == Style.DOCUMENT ||
operation.getStyle() == Style.WRAPPED ||
operation.getUse() == Use.LITERAL ||
operation.getNumInParams() >= numParams) {
rpcHandler.setOperation(operation);
try {
// If no operation name and more than one
// parameter is expected, don't
// wrap the rpcHandler in an EnvelopeHandler.
if ((operation.getStyle() == Style.DOCUMENT) &&
operation.getNumInParams() > 0) {
context.pushElementHandler(rpcHandler);
context.setCurElement(null);
} else {
context.pushElementHandler(
new EnvelopeHandler(rpcHandler));
context.setCurElement(this);
}
publishToHandler((org.xml.sax.ContentHandler) context);
// If parameter values are located in headers,
// get the information and publish the header
// elements to the rpc handler.
if (needHeaderProcessing) {
processHeaders(operation, isResponse,
context, rpcHandler);
}
// Check if the RPCParam's value match the signature of the
// param in the operation.
boolean match = true;
for ( int j = 0 ; j < params.size() && match ; j++ ) {
RPCParam rpcParam = (RPCParam)params.get(j);
Object value = rpcParam.getValue();
// first check the type on the paramter
ParameterDesc paramDesc = rpcParam.getParamDesc();
// if we found some type info try to make sure the value type is
// correct. For instance, if we deserialized a xsd:dateTime in
// to a Calendar and the service takes a Date, we need to convert
if (paramDesc != null && paramDesc.getJavaType() != null) {
// Get the type in the signature (java type or its holder)
Class sigType = paramDesc.getJavaType();
if(!JavaUtils.isConvertable(value, sigType))
match = false;
}
}
// This is not the right operation, try the next one.
if(!match) {
params = new Vector();
continue;
}
// Success!! This is the right one...
msgContext.setOperation(operation);
return;
} catch (SAXException e) {
// If there was a problem, try the next one.
savedException = e;
params = new Vector();
continue;
} catch (AxisFault e) {
// Thrown by getHeadersByName...
// If there was a problem, try the next one.
savedException = new SAXException(e);
params = new Vector();
continue;
}
}
}
if (savedException != null) {
throw savedException;
} else if (!msgContext.isClient()) {
throw new SAXException(
Messages.getMessage("noSuchOperation", name));
}
}