appendRequiredHeader(soapHeader, ADDR.getActionQName(), getAction());
// Write wsa:MessageID
if( (getReplyTo()!=null || getFaultTo()!=null) && null==getMessageID())
{
throw new AddressingException("Required addressing header missing:" + ADDR.getMessageIDQName());
}
else if (getMessageID() != null)
{
SOAPElement wsaMessageId = soapHeader.addChildElement(new NameImpl(ADDR.getMessageIDQName()));
wsaMessageId.addTextNode(getMessageID().getURI().toString());
}
// Write wsa:RelatesTo
if (getRelatesTo() != null)
{
for (Relationship rel : getRelatesTo())
{
SOAPElement wsaRelatesTo = soapHeader.addChildElement(new NameImpl(ADDR.getRelatesToQName()));
if (rel.getType() != null)
{
wsaRelatesTo.setAttribute(ADDR.getRelationshipTypeName(), getQualifiedName(rel.getType()));
}
wsaRelatesTo.addTextNode(rel.getID().toString());
}
}
// Write wsa:ReferenceParameters
ReferenceParameters refParams = getReferenceParameters();
if (refParams.getElements().size() > 0)
{
for (Object obj : refParams.getElements())
{
SOAPElement refElement = appendElement(soapHeader, obj);
QName refQName = new QName(ADDR.getNamespaceURI(), "IsReferenceParameter", ADDR.getNamespacePrefix());
refElement.addAttribute(refQName, "true");
}
}
appendElements(soapHeader, getElements());
}
catch (SOAPException ex)
{
throw new AddressingException("Cannot read ws-addressing headers", ex);
}
}