1 Reply Latest reply on Mar 20, 2019 10:23 PM by Marie Johnson

    How to validate an attachment (base 64 binary) in a web service

    Sergio Tomillero
      Share This:

      Hello !!

       

      I have created a web service that generates a record in a form with an attach file. This is the body of the method:

       

      <urn:setAttachments>

      <!--Optional:-->

      <urn:AttachmentName>MyDocument.doc</urn:AttachmentName>

      <!--Optional:-->

      <urn:AttachmentData>file:D:\MyDocument.doc</urn:AttachmentData>

      <!--Optional:-->

        <urn:AttachmentOrigSize></urn:AttachmentOrigSize>

        <urn:WebService>setAttachments</urn:WebService>

      </urn:setAttachments>

       

      This works correctly,generating the record with the specified file and returning an unique identifier.

       

      <ns0:Output>ATGAA5V0G7069APOKFSZH3EX32ZWZT</ns0:Output>

       

      The problem is when I indicate a wrong value in 'AttachmentData', as a path with a not existing file or, for instance, any text as "zzzzz"

       

      <urn:setAttachments>

      <!--Optional:-->

      <urn:AttachmentName>MyDocument2.xlsx</urn:AttachmentName>

      <!--Optional:-->

      <urn:AttachmentData>zzzzz</urn:AttachmentData>

      <!--Optional:-->

        <urn:AttachmentOrigSize></urn:AttachmentOrigSize>

        <urn:WebService>setAttachments</urn:WebService>

      </urn:setAttachments>

       

      This creates a '1 KB size attachment' instead the file does not exist. In the definition of the web service, the parameter 'AttachmentData' is defined as type base64Binary. When you create this kind of parameter, this automatically includes an embedded Default Value that cannot be deleted

       

      Therefore, it does not matter what you indicate in 'AttachmentData' that due to it has a Default Value, it will allways create an attachment and will return ok.

       

      Is there any way to validate if the value of 'AttachmentData' is correct?

       

      Thanks.

       

       

      Sergio