SOAPEnvelope req = msgContext.getRequestMessage().getSOAPEnvelope();
SOAPHeaderElement header = req.getHeaderByName(NS_URI_WSRM, "Sequence");
if (header == null)
return;
Iterator i = header.getChildElements(new PrefixedQName(NS_URI_WSU, "Identifier", null));
if (!i.hasNext()) {
// return fault
throw new AxisFault("WSRM.Fault", "Missing identifier in Sequence", null, null);
}
MessageElement el = (MessageElement)i.next();
String id = el.getValue();
Sequence seq = (Sequence)sequences.get(id);
if (seq == null) {
seq = new Sequence(id);
sequences.put(id, seq);
}
i = header.getChildElements(new PrefixedQName(NS_URI_WSRM, "MessageNumber", null));
el = (MessageElement)i.next();
// We've received a message with a given ID.
int seqNum = Integer.parseInt(el.getValue());
int nextSeq = seq.maxReceived + 1;
if (seqNum < nextSeq) {
Integer s = new Integer(seqNum);
if (seq.missing.contains(s)) {
seq.missing.remove(s);
}
} else {
if (seqNum > nextSeq) {
// Missing everything between maxReceived and this
for (int n = nextSeq; n < seqNum; n++) {
seq.missing.add(new Integer(n));
}
}
seq.maxReceived = seqNum;
}
header.setProcessed(true);
String from = null;
header = req.getHeaderByName(NS_URI_WSA, "From");
if (header != null) {
i = header.getChildElements(new PrefixedQName(NS_URI_WSA, "Address", null));
if (!i.hasNext()) {
throw new AxisFault("WSRM.NoAddress", "No <Address> element in <From> header", null, null);
}
el = (MessageElement)i.next();
from = el.getValue();