code: protected SoapAttachment findAttachment(SoapMessage soapMessage, SoapAttachment controlAttachment) {
          List<SoapAttachment> attachments = soapMessage.getAttachments();
          Attachment matching = null;
  
          if (controlAttachment.getContentId() == null) {
              if (attachments.size() == 1) {
                  matching = attachments.get(0);
              } else {
                  throw new ValidationException("Found more than one SOAP attachment - need control attachment content id for validation!");
              }
          } else {
              // try to find attachment by its content id
              for (Attachment attachment : attachments) {
                  if (controlAttachment.getContentId() != null &&
                          controlAttachment.getContentId().equals(attachment.getContentId())) {
                      matching = attachment;
                  }
              }
          }
  
          if (matching != null) {
              return SoapAttachment.from(matching);
          } else {
              throw new ValidationException(String.format("Unable to find SOAP attachment with content id '%s'", controlAttachment.getContentId()));
          }
      }
docs: Finds attachment in list of soap attachments on incoming soap message. By default
  uses content id of control attachment as search key. If no proper attachment with this content id
  was found in soap message throws validation exception.
  
  @param soapMessage
  @param controlAttachment
  @return