SOAPEnvelope env = msgContext.getRequestMessage().getSOAPEnvelope();
Vector headers = env.getHeadersByActor(acts);
Vector misunderstoodHeaders = null;
Enumeration enumeration = headers.elements();
while (enumeration.hasMoreElements()) {
SOAPHeaderElement header = (SOAPHeaderElement)enumeration.
nextElement();
if (header.getMustUnderstand() && !header.isProcessed()) {
if (misunderstoodHeaders == null)
misunderstoodHeaders = new Vector();
misunderstoodHeaders.addElement(header);
}
}
SOAPConstants soapConstants = msgContext.getSOAPConstants();
// !!! we should indicate SOAP1.2 compliance via the
// MessageContext, not a boolean here....
if (misunderstoodHeaders != null) {
AxisFault fault =
new AxisFault(soapConstants.getMustunderstandFaultQName(),
null, null,
null, null,
null);
StringBuffer whatWasMissUnderstood= new StringBuffer(256);
// !!! If SOAP 1.2, insert misunderstood fault headers here
if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
enumeration = misunderstoodHeaders.elements();
while (enumeration.hasMoreElements()) {
SOAPHeaderElement badHeader = (SOAPHeaderElement)enumeration.
nextElement();
QName badQName = new QName(badHeader.getNamespaceURI(),
badHeader.getName());
if(whatWasMissUnderstood.length() != 0) whatWasMissUnderstood.append(", ");
whatWasMissUnderstood.append( badQName.toString() );
SOAPHeaderElement newHeader = new
SOAPHeaderElement(Constants.URI_SOAP12_ENV,
Constants.ELEM_NOTUNDERSTOOD);
newHeader.addAttribute(null,
Constants.ATTR_QNAME,
badQName);
fault.addHeader(newHeader);
}