@Test public void handleMessageWithoutHeadersVerifyHeadersNotAltered() { ArrayList<SoapHeader> soapHeaders = new ArrayList<>(); when(message.get(anyString())).thenReturn(soapHeaders); interceptor.handleMessage(message); assertEquals(0, soapHeaders.size()); }
@Override public void handleMessage(Message message) { List<SoapHeader> headers = (ArrayList<SoapHeader>) message.get(SOAP_HEADER_KEY); if(!messageIdHeaderExists(headers) && !headers.isEmpty()) { Element existingHeaderElement = (Element) headers.get(0).getObject(); Element element = existingHeaderElement.getOwnerDocument().createElementNS(NAMESPACE_URI, QUALIFIED_NAME); element.appendChild(existingHeaderElement.getOwnerDocument().createTextNode("uuid:" + UUID.randomUUID().toString())); QName qname = new QName(NAMESPACE_URI, LOCAL_NAME); SoapHeader header = new SoapHeader(qname, element); header.setDirection(Header.Direction.DIRECTION_IN); headers.add(header); } }
MessageIdHeaderInterceptor extends AbstractPhaseInterceptor<Message> { @Override public void handleMessage(Message message) { List<SoapHeader> headers = (ArrayList<SoapHeader>) message.get(SOAP_HEADER_KEY); if(!messageIdHeaderExists(headers) && !headers.isEmpty()) { Element existingHeaderElement = (Element) headers.get(0).getObject(); Element element = existingHeaderElement.getOwnerDocument().createElementNS(NAMESPACE_URI, QUALIFIED_NAME); element.appendChild(existingHeaderElement.getOwnerDocument().createTextNode("uuid:" + UUID.randomUUID().toString())); QName qname = new QName(NAMESPACE_URI, LOCAL_NAME); SoapHeader header = new SoapHeader(qname, element); header.setDirection(Header.Direction.DIRECTION_IN); headers.add(header); } } }
MessageIdHeaderInterceptor extends AbstractPhaseInterceptor<Message> { @Override public void handleMessage(Message message) { List<SoapHeader> headers = (ArrayList<SoapHeader>) message.get(SOAP_HEADER_KEY); if(!messageIdHeaderExists(headers) && !headers.isEmpty()) { Element existingHeaderElement = (Element) headers.get(0).getObject(); Element element = existingHeaderElement.getOwnerDocument().createElementNS(NAMESPACE_URI, QUALIFIED_NAME); element.appendChild(existingHeaderElement.getOwnerDocument().createTextNode("uuid:" + UUID.randomUUID().toString())); QName qname = new QName(NAMESPACE_URI, LOCAL_NAME); SoapHeader header = new SoapHeader(qname, element); header.setDirection(Header.Direction.DIRECTION_IN); headers.add(header); } } MessageIdHeaderInterceptor(); }
MessageIdHeaderInterceptor extends AbstractPhaseInterceptor<Message> { @Override public void handleMessage(Message message) { List<SoapHeader> headers = (ArrayList<SoapHeader>) message.get(SOAP_HEADER_KEY); if(!messageIdHeaderExists(headers) && !headers.isEmpty()) { Element existingHeaderElement = (Element) headers.get(0).getObject(); Element element = existingHeaderElement.getOwnerDocument().createElementNS(NAMESPACE_URI, QUALIFIED_NAME); element.appendChild(existingHeaderElement.getOwnerDocument().createTextNode("uuid:" + UUID.randomUUID().toString())); QName qname = new QName(NAMESPACE_URI, LOCAL_NAME); SoapHeader header = new SoapHeader(qname, element); header.setDirection(Header.Direction.DIRECTION_IN); headers.add(header); } } MessageIdHeaderInterceptor(); @Override void handleMessage(Message message); }
MessageIdHeaderInterceptor extends AbstractPhaseInterceptor<Message> { @Override public void handleMessage(Message message) { List<SoapHeader> headers = (ArrayList<SoapHeader>) message.get(SOAP_HEADER_KEY); if(!messageIdHeaderExists(headers) && !headers.isEmpty()) { Element existingHeaderElement = (Element) headers.get(0).getObject(); Element element = existingHeaderElement.getOwnerDocument().createElementNS(NAMESPACE_URI, QUALIFIED_NAME); element.appendChild(existingHeaderElement.getOwnerDocument().createTextNode("uuid:" + UUID.randomUUID().toString())); QName qname = new QName(NAMESPACE_URI, LOCAL_NAME); SoapHeader header = new SoapHeader(qname, element); header.setDirection(Header.Direction.DIRECTION_IN); headers.add(header); } } MessageIdHeaderInterceptor(); @Override void handleMessage(Message message);  }