/** * Determine whether the inbound message represented by the message context * contains a SOAP Envelope. * * @param messageContext the current message context * @return true if the inbound message contains a SOAP Envelope, false otherwise */ public static boolean isInboundSOAPMessage(MessageContext messageContext) { XMLObject inboundMessage = messageContext.getInboundMessage(); if (inboundMessage == null) { return false; } // SOAP 1.1 Envelope if (inboundMessage instanceof Envelope) { return true; } //TODO SOAP 1.2 support when object providers are implemented return false; }
/** * Get a header block from the SOAP envelope contained within the specified message context's * {@link MessageContext#getInboundMessage()}. * * @param msgContext the message context being processed * @param headerName the name of the header block to return * @param targetNodes the explicitly specified SOAP node actors (1.1) or roles (1.2) for which the header is desired * @param isFinalDestination true specifies that headers targeted for message final destination should be returned, * false means they should not be returned * @return the list of matching header blocks */ public static List<XMLObject> getInboundHeaderBlock(MessageContext msgContext, QName headerName, Set<String> targetNodes, boolean isFinalDestination) { XMLObject inboundEnvelope = msgContext.getInboundMessage(); if (inboundEnvelope == null) { throw new IllegalArgumentException("Message context does not contain an inbound SOAP envelope"); } // SOAP 1.1 Envelope if (inboundEnvelope instanceof Envelope) { return getSOAP11HeaderBlock((Envelope) inboundEnvelope, headerName, targetNodes, isFinalDestination); } //TODO SOAP 1.2 support when object providers are implemented return Collections.emptyList(); }
/** * Check that all headers which carry the <code>soap11:mustUnderstand</code> attribute * and which are targeted to this SOAP node via the <code>soap11:actor</code> were understood by the * decoder. * * @param messageContext the message context being processed * * @throws MessageDecodingException thrown if a SOAP header requires understanding by * this node but was not understood */ private void checkUnderstoodSOAPHeaders(MessageContext messageContext) throws MessageDecodingException { Envelope envelope = (Envelope) messageContext.getInboundMessage(); Header soapHeader = envelope.getHeader(); if (soapHeader == null) { log.debug("SOAP Envelope contained no Header"); return; } List<XMLObject> headers = soapHeader.getUnknownXMLObjects(); if (headers == null || headers.isEmpty()) { log.debug("SOAP Envelope header list was either null or empty"); return; } for (XMLObject header : headers) { //TODO } }
/** * Log the decoded message to the protocol message logger. * * @param messageContext the message context to process */ protected void logDecodedMessage(MessageContext messageContext) { if(protocolMessageLog.isDebugEnabled() && messageContext.getInboundMessage() != null){ if (messageContext.getInboundMessage().getDOM() == null) { XMLObject message = messageContext.getInboundMessage(); Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(message); if (marshaller != null) { try { marshaller.marshall(message); } catch (MarshallingException e) { log.error("Unable to marshall message for logging purposes: " + e.getMessage()); } } else { log.error("Unable to marshall message for logging purposes, no marshaller registered for message object: " + message.getElementQName()); } if (message.getDOM() == null) { return; } } protocolMessageLog.debug("\n" + XMLHelper.prettyPrintXML(messageContext.getInboundMessage().getDOM())); } }