Uniface User Forum

 View Only
  • 1.  Extract files from response of WebServices / MIME / MTOM

    PARTNER
    Posted 10-22-2021 09:14
    Hello,
    I call WebService of a carrier to print a sticker on parcels I deliver.
    I test my request in SoapUI and the sticker semmes to be included in the response. The carrier told me "Our WebService uses MTOM Technology (Message Trasmission Optimization Mechabism). By this way, the sticker is attached in MIME format in the response. You will have to parse the response to extract the .pdf file of this sticker."
    Do you know how to extract such files ?
    Tks

    ------------------------------
    Laurent Mérot
    Rocket Forum Shared Account
    ------------------------------


  • 2.  RE: Extract files from response of WebServices / MIME / MTOM

    ROCKETEER
    Posted 10-28-2021 07:22

    Hello Laurent,

    I did a quick web search and most examples I can find for extracting MTOM attachments from a SOAP message is for Java or C#. And if I remember correctly then a customer from France has implemented a Java routine into their Uniface application for this specific task. Unfortunately the colleague who has worked on this case is retired now. Maybe another forum member, who has done this before, can share his experience or a small sample with the community?

    But in short: Uniface currently has no out-of-the-box solution for this. It, however, should be possible to use an external routine to extract MTOM attachments from a SOAP message and interface with it from Uniface.

    I hope this helps.



    ------------------------------
    Daniel Iseli
    Rocket Internal - All Brands
    Geneva Switzerland
    ------------------------------



  • 3.  RE: Extract files from response of WebServices / MIME / MTOM

    Posted 10-30-2021 07:51

    Hi Laurent,

    I did a quick search too and found this page reporting a php class probably equivalent to your need; it's a simple routine and it should be a very quick task to rebuilt it with Uniface.

    Hope it helps.

    Regards,
    Gianni



    ------------------------------
    Gianni Sandigliano
    Italy
    ------------------------------



  • 4.  RE: Extract files from response of WebServices / MIME / MTOM

    PARTNER
    Posted 11-08-2021 07:08
    Hello,
    Our supplier told us that the useful part of the response was just after the "%PDF 1-3" tag.
    When we test our WebService with Soapui, we can see the entier response, but in Uniface, the responses seems to be truncated as you can see in pictures.
    Is there a mean to extract the entire response in Uniface ? We tried to use the READ_CONTENT function but it was not successfull.
    Regards,
    Laurent.

    ------------------------------
    Laurent Mérot
    Rocket Forum Shared Account
    ------------------------------



  • 5.  RE: Extract files from response of WebServices / MIME / MTOM

    Posted 11-08-2021 08:20

    Hi Laurent,

    The image is clearly showing an incomplete message content: just the beginning of the attached PDF document is there.

    I suppose you are using uhttp.send() to manage a round trip to and from the SOAP web service using MIME/MTOM; if you are getting $status = 1 after it you should call read_content to complete message buffer like in the standard example:

      activate "UHTTP".send(pUrl, "GET", pUsername, pPassword, pHttpHeader, pHttpContent, vResponse)
      while ($status = 1)
        activate "UHTTP".read_Content(vMoreContent)      ; get more data from UHTTP buffer
        pHttpContent = $concat(pHttpContent, vMoreContent)
      endwhile
    

    What in your case it is not aligned to this programming mode?

    Regards,
    Gianni



    ------------------------------
    Gianni Sandigliano
    Italy
    ------------------------------



  • 6.  RE: Extract files from response of WebServices / MIME / MTOM

    PARTNER
    Posted 11-08-2021 08:40
    I would assume he was using the SOAP driver ($SOP) and the imported signature from the WSDL rather than the UHTTP component. I would suspect limits on this driver, but we use it to deliver 23Mb files as part of the patching routine, so maybe not. 

    Iain

    ------------------------------
    Iain Sharp
    Head of Technical Services
    Pci Systems Ltd
    Sheffield United Kingdom
    ------------------------------



  • 7.  RE: Extract files from response of WebServices / MIME / MTOM

    ROCKETEER
    Posted 11-08-2021 08:53
    The Content parameter of the UHTTP SEND and the READ_CONTENT operation can only handle textual data. It is possible to handle binary data when it is represented as textual data with base64 or hex encoding. In case non-textual (i.e. binary) data is encountered then it will be converted to string (which most likely will result in data corruption like e.g. truncation).

    It is possible to transfer binary files for download with the DUMP_FILE_CONTENTS operation, but it currently does not support multi-part HTTP requests (as used here). For details see the following topic in the doc: Binary File Transfers with UHTTP

    Not sure if the DUMP_FILE_CONTENTS will actually return an error when it encounters a multi-part HTTP requests. You could give it a try. In case the complete content returned by the request is written to a file then you have to extract the "useful" parts manually.

    Hope this helps.

    ------------------------------
    Daniel Iseli
    Rocket Internal - All Brands
    Geneva Switzerland
    ------------------------------



  • 8.  RE: Extract files from response of WebServices / MIME / MTOM

    PARTNER
    Posted 11-12-2021 11:46
      |   view attached
    Hi Gianni, Dianel,

    We used "dump_file_contents" function to read the complete response and it's OK ! Thousands thanks ! We did not know about this function.

    Our client is in 9.6 Uniface version and the dump_file_contents is only available in 9.7 one...but fortunately for us Uniface 9.6 can call remote service on server running in  9.7 version :-)

    Thanks again,

    ------------------------------
    Laurent Mérot
    Rocket Forum Shared Account
    ------------------------------



  • 9.  RE: Extract files from response of WebServices / MIME / MTOM

    ROCKETEER
    Posted 11-15-2021 06:03
    Hi Laurent,

    Thanks for your feedback. And you are welcome. Good to hear that it's working.

    ------------------------------
    Daniel Iseli
    Principal Technical Support Engineer
    Uniface Services
    Rocket Software, Switzerland
    ------------------------------