System.out.println("Explicit MessageAddressingProperties propagation");
System.out.println("------------------------------------------------");
// get Message Addressing Properties instance
AddressingBuilder builder = AddressingBuilder.getAddressingBuilder();
AddressingProperties maps = builder.newAddressingProperties();
// set MessageID property
AttributedURIType messageID =
WSA_OBJECT_FACTORY.createAttributedURIType();
messageID.setValue("urn:uuid:12345");
maps.setMessageID(messageID);
// associate MAPs with request context
Map<String, Object> requestContext =
((BindingProvider)port).getRequestContext();
requestContext.put(CLIENT_ADDRESSING_PROPERTIES, maps);
System.out.println("Invoking sayHi...");
String resp = port.sayHi();
System.out.println("Server responded with: " + resp + "\n");
// clear the message ID to ensure a duplicate is not sent on the
// next invocation
maps.setMessageID(null);
// set the RelatesTo property to the initial message ID, so that
// the series of invocations are explicitly related
RelatesToType relatesTo = WSA_OBJECT_FACTORY.createRelatesToType();
relatesTo.setValue(messageID.getValue());
maps.setRelatesTo(relatesTo);
System.out.println("Invoking greetMe...");
resp = port.greetMe(USER_NAME);
System.out.println("Server responded with: " + resp + "\n");