use of org.apache.cxf.ws.addressing.AddressingProperties in project ddf by codice.
the class GuestInterceptor method createAddressing.
private void createAddressing(SoapMessage message, SOAPMessage soapMessage) {
SOAPFactory soapFactory;
try {
soapFactory = SOAPFactory.newInstance();
} catch (SOAPException e) {
LOGGER.debug("Could not create a SOAPFactory.", e);
// can't add anything if we can't create it
return;
}
String addressingProperty = org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND;
AddressingProperties addressingProperties = new AddressingProperties();
try {
SOAPElement action = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_ACTION_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
action.addTextNode((String) message.get(org.apache.cxf.message.Message.REQUEST_URL));
AttributedURIType attributedString = new AttributedURIType();
String actionValue = StringUtils.defaultIfEmpty((String) message.get(SoapBindingConstants.SOAP_ACTION), "");
attributedString.setValue(actionValue);
addressingProperties.setAction(attributedString);
soapMessage.getSOAPHeader().addChildElement(action);
} catch (SOAPException e) {
LOGGER.debug("Unable to add addressing action.", e);
}
try {
SOAPElement messageId = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_MESSAGEID_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
String uuid = "urn:uuid:" + UUID.randomUUID().toString();
messageId.addTextNode(uuid);
AttributedURIType attributedString = new AttributedURIType();
attributedString.setValue(uuid);
addressingProperties.setMessageID(attributedString);
soapMessage.getSOAPHeader().addChildElement(messageId);
} catch (SOAPException e) {
LOGGER.debug("Unable to add addressing messageId.", e);
}
try {
SOAPElement to = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_TO_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
to.addTextNode((String) message.get(org.apache.cxf.message.Message.REQUEST_URL));
EndpointReferenceType endpointReferenceType = new EndpointReferenceType();
AttributedURIType attributedString = new AttributedURIType();
attributedString.setValue((String) message.get(org.apache.cxf.message.Message.REQUEST_URL));
endpointReferenceType.setAddress(attributedString);
addressingProperties.setTo(endpointReferenceType);
soapMessage.getSOAPHeader().addChildElement(to);
} catch (SOAPException e) {
LOGGER.debug("Unable to add addressing to.", e);
}
try {
SOAPElement replyTo = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_REPLYTO_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
SOAPElement address = soapFactory.createElement(org.apache.cxf.ws.addressing.Names.WSA_ADDRESS_NAME, org.apache.cxf.ws.addressing.JAXWSAConstants.WSA_PREFIX, org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker.WSA_NS);
address.addTextNode(org.apache.cxf.ws.addressing.Names.WSA_ANONYMOUS_ADDRESS);
replyTo.addChildElement(address);
soapMessage.getSOAPHeader().addChildElement(replyTo);
} catch (SOAPException e) {
LOGGER.debug("Unable to add addressing replyTo.", e);
}
message.put(addressingProperty, addressingProperties);
}
Aggregations