HTTP File upload

I’m trying to automate a file upload process to a website using HTTP.

From reading on this forum it sounds like I need to mime encode the contents of the file, and set the Content-Type to multipart/form-data before using the pub.client:HTTP to perform the upload.

Is this true? If so, then can someone tell me how I can mime encode my file?

Thanks!

Use the Built-In wm services for Mime. wMsamples contains examples of this. Be warned though there appears to be issues using these services.

Hi, indnxb.

Frank is right; MIME services from WmSamples is where to go. It won’t complete the picture, though. There has been a lot of questions about MIME-encoding messages on the Discussion Forums.

Take some time to learn from everyone else – read up!

[url=“wmusers.com”]wmusers.com is for general posting to Flow.

[url=“wmusers.com”]wmusers.com discusses general posting to Flow, too.

[url=“wmusers.com”]wmusers.com is for posting to/from SAP.

There are many more. Do a search for “MIME” and see what turns up.

Hi there,
I have read (I think) all threads on HTTP file posts to the IS, but unfortunately no one speaks about getting the actual InputStream to create the mime object. I have found a thread about creating custom content handlers but the sample code given has quite a number of bugs in it, and in the end does not do the job

Problem is that after posting a form (multipart/form-data) to the IS, the only way I can get the InputStream from the pipeline is by using (IData)pi.getProtocolProperty(“contentStream”);… When checking the info in the stream (by converting to a byteArray), it looks as if I am missing some headers.

The string looks like this:
------------------------7d33b21b40244-- 4 Content-Disposition: form-data; name=“sourceID” 11 -----------------------------7d33b21b40244 Content-Disposition: form-data; name=“fileID” 22 -----------------------------7d33b21b40244 Content-Disposition: form-data; name=“file”; filename=“D:\sqlnet.log” Content-Type: application/octet-stream (snip)

I am not quite sure why the boundaries are still present, as I assumed they would be removed from the stream before being put into the pipeline. Do you have any additional info on this or am I just going down the wrong track in handling this problem?

PS. Currently using IS 6.0.1 SP1 on both Unix & Windows 2K

Many thanks, Chris

Chris, your post states that you posted the form data to the IS, while the previous messages in this thread are about posting from the IS. For receiving multipart data in IS, you want to obtain the multipart content handler from webMethods. I believe you can get this by contacting webMethods technical support or professional services.

Skip,

Thanks for the info. I know it is the other way around, but it seems that most threads on this subject are mixed like that so I am trying my luck on various threads.
As far as I could figure out, wM does not have such a content handler, but I will try again with PS.

Thanks for the reply.

Chris

There is a “multipart/form-data” ContentHandler as part of the WmJBoss package.

Hi,
I want to uplaod file over jsp side.
in google i found a lot of Example. but i think that somting is missing.
so, i want to upload file on IS ( Integration Server ) .
Here ist the HTML Side:
<form>
<input>
<input>
</form>
this html is runing okay but by the jsp side is missing something
How can i complete this jsp-side, so that i can upload file on IS?
the JSP side:
<% Stirng filename=request.getParameter(“file”);
FileInputStream is =new FileInputStream (filename);
int ch;
while ((ch =is.read())>=0)
out.print((char) ch);
is.close();
%>

in JSP side is missing the adress of IS and maybe more.
can someone give some tip? how can i coplete the jsp seid?
thanks, Roya

Roya, if you need a quick resolve, check the shareware section of wmusers. I placed a demo package there that uses a DSP to upload the file. The services will explain to you what happens and what you need to do.
In JSP the matter is of a different nature. I would suggest you have a look at Apache Struts and see if you can incorporate those in your application. That might also save you a lot of problems.

Chris

Chris,

I too have a scenario where a (excel) file needs to be uploaded directly to a webMethods service through a JSP. I went through your shared package and it seems very useful… however, there are references to certain GDCUtils services which are not a part of the package. There’s one for writing to a file - which is not a prob at all… I have that covered, but there’s another one (GDCUtils.mime:getFormInputs)that extracts from the mimeHeader into ‘itemName’, ‘itemType’ and ‘localFilename’. I have very little or almost no understanding of the mime object and contents… this is my first attempt at it… thus, I do not know how to extract the above in absence of the getFormInputs service. Could you please share that service too? Also any helpful tips on how this all works would be greatly appreciated.

Thanks, Rohit

Chris,

Reading a couple of threads and specifications on the Mime helped me understand the structure and I was able to write a java service to extract the required info from the mimeHeader.

Thanks,
Rohit

May I have access to that DSP as well? Thanks!

Hi Chris,

I was trying to do the same kind of HTTP file transfer into my application back and forth from client machine to IS and reverse. I couldnot able to find “shareware section of wmusers” for your codes(demo). could you pls. tell where is it under?

Many thanks,

jj

Hi Rohit,
I’m also facing the same issue. I have to upload excel file to IS from DSP. Can you please share your services as I’m not able to find sample package given by Chris.

Thanks,
Vikram Jindal

Hi,

We are trying to upload an xml on JSP page through HTTP post which inturn calls the flow service.

But the pipeline is just having the filename but not the content.

Below is the form code.

To be loaded in database ?
To be loaded in cache ?
Upload the file


Following the option i tried but no luck.

– I registered content handler like this

ServerAPI.registerContentHandler(“multipart/form-data”,
new HandlerFactory_Sample());

Any inputs to this is very helpful.

Thanks !!