webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

How to capture file upload Content from dsp page

  • 1.  How to capture file upload Content from dsp page

    Posted Wed June 08, 2022 02:08 AM

    Hello experts,

    I need to upload file from a DSP page, I have created:

    1. a DSP page with form that sends data to upload.dsp page
    2. upload.dsp page that calls IS service to handle the file

    I can see in the pipeline name of the file, but content is not coming.

    3)but how to catch that content into the is service ? i tried using tracePipeline but content is not coming.

    please help how we will catch the content into the service pipeline.


    #webMethods


  • 2.  RE: How to capture file upload Content from dsp page

    Posted Wed June 08, 2022 02:22 AM

    The service should be receiving a contentStream, from which you can start reading or writing locally.
    e.g.

    Can you include your DSP page ?
    regards,
    John.


    #webMethods


  • 3.  RE: How to capture file upload Content from dsp page

    Posted Wed June 08, 2022 06:49 AM

    @John_Carter4 I have used contentStream as input, still it is not coming and throwing error (Missing Parameter: inputStream).

    Attached DSP in .txt
    fileUpload.txt (418 Bytes)
    extension as this forum is not accepting .dsp file.


    #webMethods


  • 4.  RE: How to capture file upload Content from dsp page

    Posted Wed June 08, 2022 09:47 AM

    You need to add the following to your FORM declaration ‘enctype=“multipart/form-data”’

    e.g.

    <form method="POST" enctype="multipart/form-data"
    

    You will then need to use the mime services to extract the content e.g.


    #webMethods


  • 5.  RE: How to capture file upload Content from dsp page

    Posted Wed June 08, 2022 09:57 AM

    Thank you @John_Carter4 it’s working after adding those declarations


    #webMethods


  • 6.  RE: How to capture file upload Content from dsp page

    Posted Fri June 10, 2022 01:47 AM

    @John_Carter4

    I am getting the below line at end of the content. How can I get rid of this line.

    ------WebKitFormBoundarylqskd07qksdjl–


    #webMethods


  • 7.  RE: How to capture file upload Content from dsp page

    Posted Fri June 10, 2022 03:30 AM

    Hmm, me too.
    It might be a bug I will need to look into this.
    regards,
    John.


    #webMethods


  • 8.  RE: How to capture file upload Content from dsp page

    Posted Thu June 16, 2022 12:29 PM

    @John_Carter4 How to pass input parameters (text, select, etc) along with file uploaded content to flow service via dsp when using post method in form?


    #webMethods


  • 9.  RE: How to capture file upload Content from dsp page

    Posted Fri June 17, 2022 02:27 AM

    Hi @Warrior_S - you would need to use multipart handling. I might have a sample I can share here. I will look at the samples and attached here.


    #webMethods


  • 10.  RE: How to capture file upload Content from dsp page

    Posted Fri June 17, 2022 02:44 AM

    if the additional data is limited, then you could always use query params or headers. Otherwise you need to send multiple pars as @srikanth.prathipati1803 indicated.
    regards,
    John.


    #webMethods


  • 11.  RE: How to capture file upload Content from dsp page

    Posted Fri June 17, 2022 03:24 AM

    @John_Carter4 thanks. Can you please share if you have any sample snippet for query parameters or headers.


    #webMethods


  • 12.  RE: How to capture file upload Content from dsp page

    Posted Fri June 17, 2022 04:29 AM

    Do you mean example code to generate this ?
    or example such as a request ?
    e.g.

    MIME-Version: 1.0
    Content-Type: multipart/mixed;
    boundary="XXXXboundary text"
    
    This is a multipart message in MIME format.
    
    --XXXXboundary text
    Content-Type: text/plain
    
    this is the body text
    
    --XXXXboundary text
    Content-Type: text/plain;
    Content-Disposition: attachment;
    filename="test.txt"
    
    this is the attachment text
    
    --XXXXboundary text--
    

    or

    POST / HTTP/1.1
    Host: localhost:8000
    User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:29.0) Gecko/20100101 Firefox/29.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Cookie: __atuvc=34%7C7; permanent=0; _gitlab_session=226ad8a0be43681acf38c2fab9497240; __profilin=p%3Dt; request_method=GET
    Connection: keep-alive
    Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
    Content-Length: 554
    
    -----------------------------9051914041544843365972754266
    Content-Disposition: form-data; name="text"
    
    text default
    -----------------------------9051914041544843365972754266
    Content-Disposition: form-data; name="file1"; filename="a.txt"
    Content-Type: text/plain
    
    Content of a.txt.
    
    -----------------------------9051914041544843365972754266
    Content-Disposition: form-data; name="file2"; filename="a.html"
    Content-Type: text/html
    
    <!DOCTYPE html><title>Content of a.html.</title>
    
    -----------------------------9051914041544843365972754266--
    

    the command curl is capable of sending multiple files via mime attachments e.g.

    $ curl -F "text=default" -F "file1=@a.html" -F "file1=@a.txt" localhost:5555/invoke/jc.test:receive
    

    John.


    #webMethods


  • 13.  RE: How to capture file upload Content from dsp page

    Posted Fri June 17, 2022 04:42 AM

    Forgot to add that for a DSP page all you need to do is add more form inputs and the request will automatically be submitted in multiple parts as below.

    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
    Content-Disposition: form-data;
    
    name="name" text 
    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
    Content-Disposition: form-data; 
    
    name="description" description 
    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
    Content-Disposition: form-data; 
    name="fileName"; 
    filename="test.txt" 
    Content-Type: text/plain 
    
    test file 
    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC--
    

    Interestingly each input value gets its own part and not not grouped as form data, perhaps there is a way of changing that.
    John.


    #webMethods


  • 14.  RE: How to capture file upload Content from dsp page

    Posted Thu August 04, 2022 10:39 AM

    hello @John_Carter4 and @srikanth.prathipati1803 is there any flow example to convert IData objects to multipart-formdata? i am quite confused to add each contents to the body part


    #webMethods


  • 15.  RE: How to capture file upload Content from dsp page

    Posted Thu August 04, 2022 10:03 PM

    Hi,

    I might have one sample, I will check my archives and get back again.


    #webMethods


  • 16.  RE: How to capture file upload Content from dsp page

    Posted Fri June 17, 2022 03:22 AM

    @srikanth.prathipati1803 thanks, can you please share the example so that I can use.


    #webMethods


  • 17.  RE: How to capture file upload Content from dsp page

    Posted Sat June 18, 2022 05:57 AM

    TryIt.zip (96.6 KB)
    Do refer to TryIt.v3.services.pub:processFile @Warrior_S
    Each part needs to be handled separately
    image


    #webMethods


  • 18.  RE: How to capture file upload Content from dsp page

    Posted Sun June 19, 2022 02:08 AM

    Thank you @srikanth.prathipati1803

    But how can I get other input parameters passed from page. example “Type” value from below pic.

    image


    #webMethods


  • 19.  RE: How to capture file upload Content from dsp page

    Posted Mon June 20, 2022 02:14 AM

    each one will be in a separate contentPart with a Content-Disposition called form-data
    e.g.

    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
    Content-Disposition: form-data;
    
    name="name" text 
    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
    Content-Disposition: form-data; 
    
    name="description" description 
    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC 
    Content-Disposition: form-data; 
    name="fileName"; 
    filename="test.txt" 
    Content-Type: text/plain 
    
    test file 
    ------WebKitFormBoundaryFLBl4kVBtl3F5yWC--
    

    Use pub.mime:getBodyPartContent for each one.

    regards,
    John.


    #webMethods


  • 20.  RE: How to capture file upload Content from dsp page

    Posted Wed June 22, 2022 11:38 AM

    @srikanth.prathipati1803 I have used your code and finally it worked. Below services are key part before createMimeData in order to capture the content correctly.

    pub.flow:getTransportInfo
    pub.mime:mergeHeaderAndBody

    @John_Carter4 thank you for your consistent help.


    #webMethods


  • 21.  RE: How to capture file upload Content from dsp page

    Posted Wed June 22, 2022 10:57 PM

    Glad to know it worked, lot of consultants does not know to process multi-part data in webMethods.


    #webMethods


  • 22.  RE: How to capture file upload Content from dsp page

    Posted Tue July 19, 2022 10:38 AM

    hey @srikanth.prathipati1803 i can’t install your TryIt package because it need wmGRPC, do you have the package so i can download?


    #webMethods


  • 23.  RE: How to capture file upload Content from dsp page

    Posted Tue July 19, 2022 11:05 AM

    TryIt.zip (96.6 KB)
    I have attached the package without the dependency.


    #webMethods


  • 24.  RE: How to capture file upload Content from dsp page

    Posted Fri August 05, 2022 05:48 AM

    So i want to generate this kind of message from IData, while this screenshot was made by request from postman

    i want to transform this Json request that are transformed to IData when sent to the IS

    {
    "partnerReferenceNo":"1231231111",
    "additionalInfo":{"channel":"MSM","deviceId":"VAMS"}
    }
    

    but i try to construct mimeData and addBodyPart the MimeData generated was wrong

    "mimeData": {
    "headers": {
    "name": "JsonData"
    },
    "part": {
    "headers": {
    "1231231111": "1231231111",
    "content-transfer-encoding": "7bit",
    "content-type": "text/plain"
    },
    "part": {
    "smime": "false",
    "headers": {
    "content-transfer-encoding": "7bit"
    },
    "content": "java.io.ByteArrayInputStream@41d5c6ff"
    }
    }
    

    while i want generate message similar to this

    POST / HTTP/1.1
    Host: localhost:8000
    User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:29.0) Gecko/20100101 Firefox/29.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-US,en;q=0.5
    Accept-Encoding: gzip, deflate
    Cookie: __atuvc=34%7C7; permanent=0; _gitlab_session=226ad8a0be43681acf38c2fab9497240; __profilin=p%3Dt; request_method=GET
    Connection: keep-alive
    Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
    Content-Length: 554
    
    -----------------------------9051914041544843365972754266
    Content-Disposition: form-data; name="text"
    
    text default
    -----------------------------9051914041544843365972754266
    Content-Disposition: form-data; name="file1"; filename="a.txt"
    Content-Type: text/plain
    
    Content of a.txt.
    
    -----------------------------9051914041544843365972754266
    Content-Disposition: form-data; name="file2"; filename="a.html"
    Content-Type: text/html
    
    <!DOCTYPE html><title>Content of a.html.</title>
    
    -----------------------------9051914041544843365972754266--
    

    #webMethods