Send file attachment as base64Binary in SoapUI

1.7k views Asked by At

There is an element, which is defined as base64Binary in WSDL. I attached file with ContentID ref1 and added it to SOAP request as follows:

<docBytes><xop:Include href="cid:ref1" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></docBytes>

I got following error message when I try to send it:

cvc-type.3.1.2: Element 'docBytes' is a simple type, so it must have no element information item [children]

It is working, when I paste a base64 encoded string between tags.

1

There are 1 answers

0
ou_ryperd On BEST ANSWER

That is correct, I have services where a PDF is sent, and I stored the doc as base64 byte array in a property like this:

def docContent = new File("path/to/file")
def encodedDoc = docContent.bytes.encodeBase64().toString()
testRunner.testCase.setPropertyValue("encodedDoc", encodedDoc)

Then use it with:

<docBytes>${#TestCase#encodedDoc}</docBytes>

in the request.