WsAddressingServiceEndpointDecorator extends ServiceEndpointDecorator<T> { private String getMessageId() { WSAHeaderHelper wsaHelper = new WSAHeaderHelper(); String messageId = null; if (assertion != null) { messageId = assertion.getMessageId(); } if (NullChecker.isNullish(messageId)) { messageId = wsaHelper.generateMessageID(); LOG.warn("Assertion did not contain a message ID. Generating one now... Message ID = {}", messageId); } else { messageId = wsaHelper.fixMessageIDPrefix(messageId); } return messageId; } WsAddressingServiceEndpointDecorator(ServiceEndpoint<T> decoratoredEndpoint, String wsAddressingTo,
        String wsAddressingAction, AssertionType assertion); @Override void configure();  }
@Test public void verifyMessageIdPrefix() { String messageId = "messageId"; String messageIdWithPrefix = "urn:uuid:messageId"; AssertionType assertion = new AssertionType(); assertion.setMessageId(messageId); CONNECTClient<TestServicePortType> client = createClient(null, null, assertion); BindingProvider bindingProviderPort = (BindingProvider) client.getPort(); AddressingProperties addressingProps = (AddressingProperties) bindingProviderPort.getRequestContext() .get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES); assertEquals(messageIdWithPrefix, addressingProps.getMessageID().getValue()); }
@Test public void verifyNullRelatesTo() { String wsAddressingTo = "wsAddressingTo"; String wsAddressingAction = "wsAddressingAction"; String messageId = "urn:uuid:messageId"; AssertionType assertion = new AssertionType(); assertion.setMessageId(messageId); CONNECTClient<TestServicePortType> client = createClient(wsAddressingTo, wsAddressingAction, assertion); BindingProvider bindingProviderPort = (BindingProvider) client.getPort(); AddressingProperties addressingProps = (AddressingProperties) bindingProviderPort.getRequestContext() .get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES); assertEquals(wsAddressingTo, addressingProps.getTo().getValue()); assertEquals(wsAddressingAction, addressingProps.getAction().getValue()); assertEquals(messageId, addressingProps.getMessageID().getValue()); assertEquals(null, addressingProps.getRelatesTo()); }
@Test public void verifyEmptyRelatesTo() { String wsAddressingTo = "wsAddressingTo"; String wsAddressingAction = "wsAddressingAction"; String messageId = "urn:uuid:messageId"; AssertionType assertion = new AssertionType(); assertion.setMessageId(messageId); CONNECTClient<TestServicePortType> client = createClient(wsAddressingTo, wsAddressingAction, assertion); BindingProvider bindingProviderPort = (BindingProvider) client.getPort(); AddressingProperties addressingProps = (AddressingProperties) bindingProviderPort.getRequestContext() .get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES); assertEquals(wsAddressingTo, addressingProps.getTo().getValue()); assertEquals(wsAddressingAction, addressingProps.getAction().getValue()); assertEquals(messageId, addressingProps.getMessageID().getValue()); assertEquals(null, addressingProps.getRelatesTo()); }