public void writeHeaders(SOAPMessage message) throws AddressingException
{
try
{
SOAPFactoryImpl factory = (SOAPFactoryImpl)SOAPFactory.newInstance();
SOAPHeader soapHeader = message.getSOAPHeader();
// Add the xmlns:wsa declaration
soapHeader.addNamespaceDeclaration(ADDR.getNamespacePrefix(), ADDR.getNamespaceURI());
// Write wsa:To
if (getTo() != null)
{
SOAPElement element = soapHeader.addChildElement(new NameImpl(ADDR.getToQName()));
element.addTextNode(getTo().getURI().toString());
}
// Write wsa:From
if (getFrom() != null)
{
EndpointReferenceImpl epr = (EndpointReferenceImpl)getFrom();
epr.setRootQName(ADDR.getFromQName());
SOAPElement soapElement = factory.createElement(epr.toElement());
soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
soapHeader.addChildElement(soapElement);
}
// Write wsa:ReplyTo
if (getReplyTo() != null)
{
EndpointReferenceImpl epr = (EndpointReferenceImpl)getReplyTo();
epr.setRootQName(ADDR.getReplyToQName());
SOAPElement soapElement = factory.createElement(epr.toElement());
soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
soapHeader.addChildElement(soapElement);
}
// Write wsa:FaultTo
if (getFaultTo() != null)
{
EndpointReferenceImpl epr = (EndpointReferenceImpl)getFaultTo();
epr.setRootQName(ADDR.getFaultToQName());
SOAPElement soapElement = factory.createElement(epr.toElement());
soapElement.removeNamespaceDeclaration(ADDR.getNamespacePrefix());
soapHeader.addChildElement(soapElement);
}
appendRequiredHeader(soapHeader, ADDR.getActionQName(), getAction());