473,737 Members | 7,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using HTTP request to POST XML files?

Hi
Sorry if this is posted in the wrong group but I'm brand new to this
area. Basically I've got to post some XML documents to an external
server using HTTP web request (POST, not GET) and be able to receive
files back. I've got the XML file generated and checked over, but I
just dont know how to go about the post process. I've got a feeling I'm
supposed to create a form in my ASP application with an action which
points at the URL I've got for the external server, but I don't know
how to "attach" the XML files I'm sending. Do I need to embed the files
in the form or do I "point" the form at the files or what?

If anyone could give me some pointers to get me started I'd really
appreciate it. Any sample code would also be gratefully received :-)

Thanks

Paul

Nov 12 '05 #1
3 11290


Paul M wrote:
Basically I've got to post some XML documents to an external
server using HTTP web request (POST, not GET) and be able to receive
files back. I've got the XML file generated and checked over, but I
just dont know how to go about the post process. I've got a feeling I'm
supposed to create a form in my ASP application with an action which
points at the URL I've got for the external server, but I don't know
how to "attach" the XML files I'm sending.


Are you using classic ASP or ASP.NET?
With classic ASP you use MSXML e.g.
Set XmlDocument = Server.CreateOb ject("Msxml2.DO MDocument.4.0")
XmlDocument.asy nc = False
XmlDocument.loa d Server.MapPath( "file.xml")
Set HttpRequest = Server.CreateOb ject("Msxml2.Se rverXMLHTTP.4.0 ")
HttpRequest.ope n "POST", "http://example.com/dir/whatever.jsp", False
HttpRequest.sen d XmlDocument
With .NET you have more generic objects so some more coding is
necessary, look into WebRequest/HttpWebRequest.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Many thanks - looks like it's what I needed. I'll give it a try.

Thanks again

Paul

Nov 12 '05 #3
Paul M wrote:
Hi
Sorry if this is posted in the wrong group but I'm brand new to this
area. Basically I've got to post some XML documents to an external
server using HTTP web request (POST, not GET) and be able to receive
files back. I've got the XML file generated and checked over, but I
just dont know how to go about the post process. I've got a feeling
I'm supposed to create a form in my ASP application with an action
which points at the URL I've got for the external server, but I don't
know how to "attach" the XML files I'm sending. Do I need to embed
the files in the form or do I "point" the form at the files or what?

If anyone could give me some pointers to get me started I'd really
appreciate it. Any sample code would also be gratefully received :-)


This is a sample method that illustrates how to use
Syetem.Net.Http WebRequest/Response to post XML:

public void PostXml(string url, string xml, Encoding enc)
{
byte[] bytes = enc.GetBytes(xm l);
HttpWebRequest request = (HttpWebRequest ) WebRequest.Crea te(url);
request.Method = "POST";
request.Content Length = bytes.Length;
request.Content Type = "text/xml";
using (Stream requestStream = request.GetRequ estStream())
{
requestStream.W rite(bytes, 0, bytes.Length);
}

using (HttpWebRespons e response =
(HttpWebRespons e) request.GetResp onse())
{
if (response.Statu sCode != HttpStatusCode. OK)
{
string message = String.Format(
"POST failed. Received HTTP {0}",
response.Status Code);
throw new ApplicationExce ption(message);
}
}
}

Actually, this method posts an arbitrary string encoded with an
arbitrary encoding-- the only thing that makes it XML specific is the
Content-Type text/xml.

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3597
by: Pieter Edelman | last post by:
Hi all, I'm trying to submit some data using a POST request to a HTTP server with BASIC authentication with python, but I can't get it to work. Since it's driving me completely nuts, so here's my cry for help. The server is an elog logbook server (http://midas.psi.ch/elog/). It is protected with a password and an empty username. I can login both using urllib and urllib2 (suppose the password is "foobar", the logbook is running on port...
15
3722
by: tabonni | last post by:
Hi I try to grab the checked files from HTML page and then send those PDF files as attachments. It can just send email, there are no PDF files attached. Can anybody point out my error? My idea is: When people check the check boxes in HTML page for the PDF files, it will transfer the files' name to ASP page. Then, it will attach it in the email.
2
1727
by: parseint | last post by:
Hi, Im trying to send a files using a HTTP POST request in my Window Application. I also have a progressbar that is being updated whil uploading. I have managed to send a file using HTTP PUT, but not HTT POST. I also want to send a username and password, as if it was get?username=myuser&pass=mypass. The WebForm1.aspx is from th following article http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q323246
3
2679
by: Brian Birtle | last post by:
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible to build a file upload progress meter using ASP.NET" **** First person to prove me wrong gets "All Time .NET Programming GOD" listing in my address book and (optionally) their name listed on my "news" page of my birtle.com website (listed as "Jane Smith is a Programming GOD") for at least a month. Why not take a moment to read more and possibly boost your ego to all time...
1
1846
by: Asha | last post by:
greetings, i need to upload an .xls file using a secure connection. so i though of using https... can i know how this can be done?
3
1450
by: darin dimitrov | last post by:
Hello, I have the following Html form: <form name="submitForProcess" action="http://localhost/xml/process.aspx" method="post" enctype="multipart/form-data"> <input type="text" name="customerId" value="5" /><br /> <input type="text" name="customerName" value="Johnson" /><br />
7
17333
by: Mark Waser | last post by:
Hi all, I'm trying to post multipart/form-data to a web page but seem to have run into a wall. I'm familiar with RFC 1867 and have done this before (with AOLServer and Tcl) but just can't seem to get it to work in Visual Basic. I tried coding it once myself from scratch and then modified a class that I found on a newsgroup (referenced below). Both seem to be doing the same thing and neither works (or rather, they seem to work but the...
6
12594
by: Julien | last post by:
Hello, I have some files located in a file server and managed by a SQL database from a web based interface using ASP + VBSCRIPT technology. I need to automatically copy those files to a web folder. I that possible? Thanks.
5
4464
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know if I have the entirely wrong approach, but my code is below. Any or all help is appreciated! What currently happens is that the getdivision.php script works perfectly and gives me an entire table of correct data. The problem is that when I click...
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9258
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9207
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6749
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3278
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.