Forum Discussion

frarev's avatar
frarev
New Contributor
7 years ago
Solved

How to send an array of byte via SOAPUI

Hi, I'm a new user of SOAPUI and i have successfully tested some SOAP Web Services.

 

But i have a problem with one : one of the requested parameters is a byte array containing a PDF document (obviously not encoded in BASE64)

I have attached in SOAPUI the PDF file with a CID reference: see the red parameters below.

 

How to send it as an array of byte with SOAPUI ? 

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wf="http://wf.soap.bdocinteractive.bdoc.com" xmlns:x-="http://xml.apache.org/xml-soap">
<soapenv:Header/>
<soapenv:Body>
<wf:executeWorkflowAction>
<wf:username>franck</wf:username>
<wf:password>franck</wf:password>
<wf:buiId>380</wf:buiId>
<wf:actionId>9600</wf:actionId>
<wf:comment>attached PDF with SOAP</wf:comment>
<wf:params>
<!--Zero or more repetitions:-->
<x-:item>
<x-:key>fileContentType</x-:key>
<x-:value>application/pdf</x-:value>
</x-:item>
<x-:item>
<x-:key>fileFileName</x-:key>
<x-:value>Constat.pdf</x-:value>
</x-:item>
<x-:item>
<x-:key>content</x-:key>
<x-:value>cid:123456789</x-:value>
</x-:item>

</wf:params>
</wf:executeWorkflowAction>
</soapenv:Body>
</soapenv:Envelope>

 

 

SOAPUI answers : 

 

<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>java.lang.ClassCastException: java.lang.String cannot be cast to [B</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">DESKTOP-C7BTNIN</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

  • Finally,, with the help of someone in my IT who knows SOAPUI i changed my request and now it works succesfully : 

     

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wf="http://wf.soap.bdocinteractive.bdoc.com" xmlns:x-="http://xml.apache.org/xml-soap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header/>
    <soapenv:Body>
    <wf:executeWorkflowAction>
    <wf:username>franck</wf:username>
    <wf:password>franck</wf:password>
    <wf:buiId>384</wf:buiId>
    <wf:actionId>9600</wf:actionId>
    <wf:comment>Ajout automatique pièce jointe par SOAP</wf:comment>
    <wf:params>
    <!--Zero or more repetitions:-->
    <x-:item>
    <x-:key>fileContentType</x-:key>
    <x-:value>application/pdf</x-:value>
    </x-:item>
    <x-:item>
    <x-:key>fileFileName</x-:key>
    <x-:value>Constat.pdf</x-:value>
    </x-:item>
    <x-:item>
    <x-:key>content</x-:key>
    <x-:value xsi:type="xsd:base64Binary">cid:1234567890</x-:value>
    </x-:item>

    </wf:params>
    </wf:executeWorkflowAction>
    </soapenv:Body>
    </soapenv:Envelope>

5 Replies

    • frarev's avatar
      frarev
      New Contributor

      Hi JHunt.

       

      Yes I saw that post and I attached my files with a CID tag as you can see in my post written in red in soapenv.

       

      The problem is that the binary file with this method seems to be transfered as a string and my Web Service is waiting an array of bytes.

      I suppose it's the reason why I get in the SoapUI answer this message : java.lang.ClassCastException: java.lang.String cannot be cast to [B.

       

      I don't see how to set the binary content as an array of bytes or perharps I wrongly read the article you sent in your post.

       

      Thanks for any help.

  • JHunt's avatar
    JHunt
    Community Hero

    Entering cid:xxx relates to the section on MTOM.

     

    Can you please try as per the Inline Files section? It should be using file:xxx, and you need to Enable Inline Files in the request's properties in the bottom-left.

    • frarev's avatar
      frarev
      New Contributor

      So i enabled Inline Files to True and changed my SOAPUI projetct like this : 

       

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wf="http://wf.soap.bdocinteractive.bdoc.com" xmlns:x-="http://xml.apache.org/xml-soap">
      <soapenv:Header/>
      <soapenv:Body>
      <wf:executeWorkflowAction>
      <wf:username>franck</wf:username>
      <wf:password>franck</wf:password>
      <wf:buiId>384</wf:buiId>
      <wf:actionId>9600</wf:actionId>
      <wf:comment>Ajout automatique pièce jointe par SOAP</wf:comment>
      <wf:params>
      <!--Zero or more repetitions:-->
      <x-:item>
      <x-:key>fileContentType</x-:key>
      <x-:value>application/pdf</x-:value>
      </x-:item>
      <x-:item>
      <x-:key>fileFileName</x-:key>
      <x-:value>Constat.pdf</x-:value>
      </x-:item>
      <x-:item>
      <x-:key>content</x-:key>
      <x-:value>file:C:/Constat.pdf</x-:value>
      </x-:item>

      </wf:params>
      </wf:executeWorkflowAction>
      </soapenv:Body>
      </soapenv:Envelope>

       

      And it doesn't work with same error : 

      <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>java.lang.ClassCastException: java.lang.String cannot be cast to [B</faultstring>
      <detail>
      <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">DESKTOP-C7BTNIN</ns1:hostname>
      </detail>
      </soapenv:Fault>
      </soapenv:Body>
      </soapenv:Envelope>

       

      • frarev's avatar
        frarev
        New Contributor

        Finally,, with the help of someone in my IT who knows SOAPUI i changed my request and now it works succesfully : 

         

        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wf="http://wf.soap.bdocinteractive.bdoc.com" xmlns:x-="http://xml.apache.org/xml-soap" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Header/>
        <soapenv:Body>
        <wf:executeWorkflowAction>
        <wf:username>franck</wf:username>
        <wf:password>franck</wf:password>
        <wf:buiId>384</wf:buiId>
        <wf:actionId>9600</wf:actionId>
        <wf:comment>Ajout automatique pièce jointe par SOAP</wf:comment>
        <wf:params>
        <!--Zero or more repetitions:-->
        <x-:item>
        <x-:key>fileContentType</x-:key>
        <x-:value>application/pdf</x-:value>
        </x-:item>
        <x-:item>
        <x-:key>fileFileName</x-:key>
        <x-:value>Constat.pdf</x-:value>
        </x-:item>
        <x-:item>
        <x-:key>content</x-:key>
        <x-:value xsi:type="xsd:base64Binary">cid:1234567890</x-:value>
        </x-:item>

        </wf:params>
        </wf:executeWorkflowAction>
        </soapenv:Body>
        </soapenv:Envelope>