protected MessagePartInfo findMessagePart(Exchange exchange, Collection<OperationInfo> operations,
QName name, boolean client, int index,
Message message) {
Endpoint ep = exchange.get(Endpoint.class);
MessagePartInfo lastChoice = null;
BindingMessageInfo msgInfo = null;
BindingOperationInfo boi = null;
for (Iterator<OperationInfo> itr = operations.iterator(); itr.hasNext();) {
OperationInfo op = itr.next();
boi = ep.getEndpointInfo().getBinding().getOperation(op);
if (boi == null) {
continue;
}
if (client) {
msgInfo = boi.getOutput();
} else {
msgInfo = boi.getInput();
}
if (msgInfo == null) {
itr.remove();
continue;
}
Collection bodyParts = msgInfo.getMessageParts();
if (bodyParts.size() == 0 || bodyParts.size() <= index) {
itr.remove();
continue;
}
MessagePartInfo p = (MessagePartInfo)msgInfo.getMessageParts().get(index);
if (name.getNamespaceURI() == null || name.getNamespaceURI().length() == 0) {
// message part has same namespace with the message
name = new QName(p.getMessageInfo().getName().getNamespaceURI(), name.getLocalPart());
}
if (name.equals(p.getConcreteName())) {
exchange.put(BindingOperationInfo.class, boi);
exchange.put(OperationInfo.class, boi.getOperationInfo());
exchange.setOneWay(op.isOneWay());
return p;
}
if (XSD_ANY.equals(p.getTypeQName())) {
lastChoice = p;
} else {
itr.remove();
}
}
if (lastChoice != null) {
setMessage(message, boi, client, boi.getBinding().getService(), msgInfo.getMessageInfo());
}
return lastChoice;
}