Call templates - Adding an attachment to a SOAP call

At the moment I am building a (SOAP) connection with another system based on Call Templates. This works very well and it is an easy way to implement all the webservices the connection has to support.

But now I have to implement an webservice that is slightly different from the previous ones. Implementing this webservice makes it possible to upload documents to the system from Novulo.

I already created a test project for this Document webservice in SOAPui and that works. I can add an attachment in SOAPui and upload the file to the system. Now I am wondering if it possible to configure the connection with this Document webservice by using the call templates.

I know how to configure a call template process, the template itself and related exportdefinitions (request) and importdefinitions (response processing) etc.

But how do I configure a call template to make an request that includes an attachment?

Below is an example of a succesfull request from SOAPui, I added the attachment in SOAPui manually (see also SOAP Attachments and Files | SoapUI

The request example:

Thu Jul 04 15:48:59 CEST 2024: DEBUG: http-outgoing >> 
POST /ExampleWebServices/services/DocumentWebservice HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: multipart/related; type="text/xml"; start="<rootpart@soapui.org>"; boundary="----=_Part_13_1100879049.1720100939741"
SOAPAction: ""
MIME-Version: 1.0
Content-Length: 2050
Host: wit.exampletest.nl
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/16.0.2)


------=_Part_13_1100879049.1720100939741
Content-Type: text/xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <rootpart@soapui.org>

<soapenv:Envelope xmlns:gen="http://generic.webservice.common.example.nl " xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-token"><wsse:Username>USER</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">token==</wsse:Nonce><wsu:Created>2024-07-04T13:48:59.740Z</wsu:Created></wsse:UsernameToken></wsse:Security></soapenv:Header>
   <soapenv:Body>
      <gen:uploadDocument soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <documentWebservice xsi:type="example:DocumentWebservice" xmlns:eab="http://www.logicacmg.com/ExampleWebservices">
            <dataHandler href="testbijlage.txt" xsi:type="example:DataHandler">1</dataHandler>
            <description xsi:type="xsd:string">Voorbeeld</description>
            <filename xsi:type="xsd:string">testbijlage.txt</filename>
         </documentWebservice>
      </gen:uploadDocument>
   </soapenv:Body>
</soapenv:Envelope>

------=_Part_13_1100879049.1720100939741
Content-Type: text/plain; charset=us-ascii; name=testbijlage.txt
Content-Transfer-Encoding: 7bit
Content-ID: <testbijlage.txt>
Content-Disposition: attachment; name="testbijlage.txt"; filename="testbijlage.txt"


Test

------=_Part_13_1100879049.1720100939741--

Hey Geertjan,

I checked with @m.gechev and @Tomaat132 and apparently we do not yet support sending binary file payloads with POST calls.
I created “SR62876 Upload files via http” as an internal ticket to look into the options. I also referenced your post.

The only workaround I can think of currently is to encode files as a base64 string and then send them in the body.

Let me know if you have any further questions and also if you found another solution to your problem!

Hej Joachim,

thank you for your reply!

I tried sending a file as base64 string by adding a element like you suggested but that doesn’t work. In that case the webservice returns an error telling I am using an invalid element:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Server.userException</faultcode>
         <faultstring>org.xml.sax.SAXException: Invalid element in nl.vnab.eabs.common.webservice.valueobjects.DocumentWebserviceVO - fileContent</faultstring>
         <detail>
            <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">VPS-219-21-8.transfer-solutions.com</ns1:hostname>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

So I will keep an eye on SR62876 :slight_smile: and do a search for other solutions.

Thanks!

Hey Geertjan!

I have built M10074 r105 that allows for uploading files, but without an additional body. It works for PUT and POST:

I am waiting for plugin changes still to also allow for adding a body.
Maybe this small change helps you in the meantime.

Regards
Joachim

1 Like