When defining message elements in a SOAPam Client or Server definition files, whether or not an element is optional is determined by the value of the element's minOccurs attribute. The minOccurs attribute is most frequently used to specify the minimum number of elements that must appear in an array. But this attribute may also be used to indicate whether or not a non-array element is optional. Setting the attribute minOccurs="0" on any element makes the element optional. For example:
<element name="anOptionalElement" type="string" size="32" minOccurs="0" />
<element name="aRequiredElement" type="string" size="32" minOccurs="1" />
<element name="anotherRequiredElement" type="string" size="32" />
Note that because the default value of minOccurs is 1, any element that does not have the minOccurs attribute is required.
In addition to setting minOccurs="0" on an element to indicate that it's optional, applications must set the value of the associated IPM field correctly to indicate to the SOAPAM or SOAPAMCP process that the element should not be included when the outbound SOAP message is created. This is accomplished by filling the field with the field's stringPadding character. For example, for the above type definition, if the stringPadding value for anOptionalElement element is "spaces", then filling the associated IPM element with spaces will cause the element to be omitted from the SOAP message. On inbound SOAP messages, if the element is not present then the associated IPM element will be filled with the string padding character.