/** * Get the <code>soap11:mustUnderstand</code> attribute from a given SOAP object. * * @param soapObject the SOAP object to add the attribute to * * @return value of the mustUnderstand attribute, or false if not present */ public static boolean getSOAP11MustUnderstandAttribute(@Nonnull final XMLObject soapObject) { if (soapObject instanceof MustUnderstandBearing) { XSBooleanValue value = ((MustUnderstandBearing) soapObject).isSOAP11MustUnderstandXSBoolean(); if (value != null) { return value.getValue(); } } if (soapObject instanceof AttributeExtensibleXMLObject) { String value = StringSupport.trimOrNull(((AttributeExtensibleXMLObject) soapObject) .getUnknownAttributes().get(MustUnderstandBearing.SOAP11_MUST_UNDERSTAND_ATTR_NAME)); return Objects.equals("1", value) || Objects.equals("true", value); } return false; }
/** * Adds a <code>soap11:mustUnderstand</code> attribute to the given SOAP object. * * @param soapObject the SOAP object to add the attribute to * @param mustUnderstand whether mustUnderstand is true or false */ public static void addSOAP11MustUnderstandAttribute(@Nonnull final XMLObject soapObject, boolean mustUnderstand) { if (soapObject instanceof MustUnderstandBearing) { ((MustUnderstandBearing) soapObject).setSOAP11MustUnderstand(new XSBooleanValue(mustUnderstand, true)); } else if (soapObject instanceof AttributeExtensibleXMLObject) { ((AttributeExtensibleXMLObject) soapObject).getUnknownAttributes().put( MustUnderstandBearing.SOAP11_MUST_UNDERSTAND_ATTR_NAME, new XSBooleanValue(mustUnderstand, true).toString()); } else { throw new IllegalArgumentException( "Specified object was neither MustUnderstandBearing nor AttributeExtensible"); } }