// Do SOAP semantics here
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage("semanticCheck00"));
}
Message msg = msgContext.getCurrentMessage();
if (msg == null)
return; // nothing to do if there's no message
SOAPEnvelope env = msg.getSOAPEnvelope();
Vector headers = null;
if (service != null) {
ArrayList acts = service.getActors();
headers = env.getHeadersByActor(acts);
} else {
headers = env.getHeaders();
}
// 1. Check mustUnderstands
Vector misunderstoodHeaders = null;
Enumeration enumeration = headers.elements();
while (enumeration.hasMoreElements()) {
SOAPHeaderElement header = (SOAPHeaderElement) enumeration.
nextElement();
// Ignore header, if it is a parameter to the operation
if(msgContext != null && msgContext.getOperation() != null) {
OperationDesc oper = msgContext.getOperation();
if(oper.getParamByQName(header.getQName())!=null) {
continue;
}
}
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);
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());
// !!! If SOAP 1.2, insert misunderstood fault headers here
if ( soapConstants == SOAPConstants.SOAP12_CONSTANTS ) {
SOAPHeaderElement newHeader = new
SOAPHeaderElement(Constants.URI_SOAP12_ENV,
Constants.ELEM_NOTUNDERSTOOD);
newHeader.addAttribute(null,
Constants.ATTR_QNAME,
badQName);
fault.addHeader(newHeader);
}
}
fault.setFaultString(Messages.getMessage("noUnderstand00",
whatWasMissUnderstood.toString()));
throw fault;
}