if (false == isSoap11)
{
throw new NotImplementedException("TODO: implement SOAP 12 serialization");
}
RMConstants wsrmConstants = provider.getConstants();
// Add xmlns:wsrm declaration
soapEnvelope.addNamespaceDeclaration(wsrmConstants.getPrefix(), wsrmConstants.getNamespaceURI());
// write required wsrm:SequenceFault element
QName sequenceFaultQName = wsrmConstants.getSequenceFaultQName();
SOAPElement sequenceFaultElement = soapEnvelope.getHeader().addChildElement(sequenceFaultQName);
// write required wsrm:FaultCode element
RMFault rmFault = (RMFault)o.getDetail();
QName faultCodeQName = wsrmConstants.getFaultCodeQName();
String subcode = wsrmConstants.getPrefix() + ":" + rmFault.getFaultCode().getSubcode().getValue();
sequenceFaultElement.addChildElement(faultCodeQName).setValue(subcode);
Map<String, Object> details = rmFault.getDetails();
if (details.size() > 0)
{
for (Iterator<String> i = details.keySet().iterator(); i.hasNext(); )
{
// write optional wsrm:Detail elements
QName detailQName = wsrmConstants.getDetailQName();
SOAPElement detailElement = sequenceFaultElement.addChildElement(detailQName);
String key = i.next();
if (RMFaultConstant.IDENTIFIER.equals(key))
{
// write optional wsrm:Identifier element
String sequenceId = (String)details.get(key);
QName identifierQName = wsrmConstants.getIdentifierQName();
detailElement.addChildElement(identifierQName).setValue(sequenceId);
}
else if (RMFaultConstant.ACKNOWLEDGEMENT.equals(key))
{
// write optional wsrm:AcknowledgementRange element
RMSequenceAcknowledgement.RMAcknowledgementRange ackRange = (RMSequenceAcknowledgement.RMAcknowledgementRange)details.get(key);
QName acknowledgementRangeQName = wsrmConstants.getAcknowledgementRangeQName();
QName upperQName = wsrmConstants.getUpperQName();
QName lowerQName = wsrmConstants.getLowerQName();
SOAPElement acknowledgementRangeElement = detailElement.addChildElement(acknowledgementRangeQName);
// write required wsrm:Lower attribute
acknowledgementRangeElement.addAttribute(lowerQName, String.valueOf(ackRange.getLower()));
// write required wsrm:Upper attribute
acknowledgementRangeElement.addAttribute(upperQName, String.valueOf(ackRange.getUpper()));
}
else if (RMFaultConstant.MAX_MESSAGE_NUMBER.equals(key))
{
// write optional wsrm:MaxMessageNumber element
Long maxMessageNumber = (Long)details.get(key);
QName maxMessageNumberQName = wsrmConstants.getMaxMessageNumberQName();
detailElement.addChildElement(maxMessageNumberQName).setValue(maxMessageNumber.toString());
}
else throw new IllegalArgumentException("Can't serialize detail with key " + key);
}
}