Service Virtualization

 View Only
Expand all | Collapse all

Read a SOAP request in a VS with an attached binary MTOM jpg file and save the file.

  • 1.  Read a SOAP request in a VS with an attached binary MTOM jpg file and save the file.

    Broadcom Employee
    Posted May 19, 2023 03:47 AM
      |   view attached

    A customer wanted to send a SOAP request to a VS with an attached binary MTOM jpg file and then save the file. The jpg file appeared to not be treated as binary and was changed.
    It took some time to develop the code in a script step to extract the jpg file from the request and save as a file but eventually this succeeded. 

    The pitfall was this line (where DevTest converted everything to text):
    ByteArrayDataSource bads = new ByteArrayDataSource(testExec.getStateString("lisa.vse.http.current.transaction",""), "application/xop+xml" ) ;

    The correct way is to get the RAW inbound payload:
    ByteArrayDataSource bads = new ByteArrayDataSource(testExec.getStateObject("lisa.vse.http.current.transaction.raw"), "application/xop+xml" ) ;

    The developer was happy to share the script step code.

    Attachment(s)

    txt
    script step code.txt   7 KB 1 version


  • 2.  RE: Read a SOAP request in a VS with an attached binary MTOM jpg file and save the file.

    Posted Jun 02, 2023 01:44 AM

    Thanks for sharing this John



    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------