Programatically Build and Post Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All:

I've got, what appears to be a simple problem, but am having a brain cramp
on determining the best way to implement. Here is the requirement (I am using
ASP.net v1.1)

User enters information in web form (OK)
User submits form (OK)
On form submission, parse data and store as XML to a file on the server (OK)
Automatically send the XML file to a remote server as an HTTP POST (Problem)

I've investigated the HTTP Response object and haven't found the right way
of capturing the XML file, applying the HTTP Header, and Posting this to the
external page. Creating the text string w/
<Form...MimeType=multipart/form-data... Input Type=File... etc is not a
problem. The problem is how to take this string and stream it to the
appropriate location.

Thanks for any help you can provide.

Tom
 
Hi Tom,

Based on your description, you 're wanting to programly send a xml file to
a remote site?

Regardless of the former three items you mentioned below:
=======================================
User enters information in web form (OK)
User submits form (OK)
On form submission, parse data and store as XML to a file on the server (OK)
Automatically send the XML file to a remote server as an HTTP POST (Problem)
=======================================

Let's just focus on the 4th one

Automatically send the XML file to a remote server as an HTTP POST (Problem)

Is the remote server a certain server in your local enviorment , also is
there a certain service( asp.net page or isapi ) which will accept the post
request ( the file stream)? If there is a certain page, then we can use
the
System.Net.HttpWebRequest class to do such task. Here is a certain tech
article discussing on this, you can have a look:

#UploadFileEx: C#'s WebClient.UploadFile with more functionality
http://www.thecodeproject.com/csharp/UploadFileEx.asp#xx972854xx

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Steve:

Thanks for your response.

The target is a remote URL from another company
The receiver is a Java Servlet
The client's requirement is that we encapsulate the XML document into a
<Form url=www.remotecompany.servlet.com> and send via HTTP.
If I were manually testing, I could build a simple form with an <Input
Type=File> and place the address of the XML document inot the input.
Upon submit, an HTTP stream w/ the file would be sent to the client

My question is how to create this stream programatically without a form
interaction with a user.

Thanks again,

Tom
 
Hi Tom,

Yes, I've got your requirement that it is how to programly make a HTTP post
(which send some post items and a file stream) just like the user submit a
certain page which some text field and file upload field.
Have you had a chance to check the article I provided in the last message,
it is just discussing simulate web page's post request via the .net's
HttpWebRequest component:

#UploadFileEx: C#'s WebClient.UploadFile with more functionality
http://www.thecodeproject.com/csharp/UploadFileEx.asp#xx972854xx

and here is a blog version of it.

http://blogs.ronaco.com/Blogs/rwilson/articles/174.aspx

If anything unclear on that , please feel free to let me know.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top