473,396 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to POST multiple xml to a WebService

Actually I have the code in c# to do an httpwebrequest with a POST method sending one XML and receiving an XML answer and saving it, here is the code:

public static XmlDocument PostXMLTransaction(string v_strURL)
{
//Declare XMLResponse document
XmlDocument XMLResponse = null;

//Declare an HTTP-specific implementation of the WebRequest class.
HttpWebRequest objHttpWebRequest;

//Declare an HTTP-specific implementation of the WebResponse class
HttpWebResponse objHttpWebResponse = null;

//Declare a generic view of a sequence of bytes
Stream objRequestStream = null;
Stream objResponseStream = null;

//Declare XMLReader
XmlTextReader objXMLReader;

//Creates an HttpWebRequest for the specified URL.
objHttpWebRequest = (HttpWebRequest)WebRequest.Create(v_strURL);

try
{
//---------- Start HttpRequest

//Set HttpWebRequest properties
byte[] bytes;
bytes = System.Text.Encoding.UTF8.GetBytes("C:\\Documents\ \Aplicacion1\\Aplicacion1\\absisSIHttpProfileTO.xm l");
objHttpWebRequest.Method = "POST";
objHttpWebRequest.ContentLength = bytes.Length;
objHttpWebRequest.ContentType = "text/xml; encoding='utf-8'";

//Get Stream object
objRequestStream = objHttpWebRequest.GetRequestStream();

//Writes a sequence of bytes to the current stream
objRequestStream.Write(bytes, 0, bytes.Length);

//Close stream
objRequestStream.Close();

//---------- End HttpRequest

//Sends the HttpWebRequest, and waits for a response.
objHttpWebResponse = (HttpWebResponse)objHttpWebRequest.GetResponse();

//---------- Start HttpResponse
if (objHttpWebResponse.StatusCode == HttpStatusCode.OK)
{
//Get response stream
objResponseStream = objHttpWebResponse.GetResponseStream();

//Load response stream into XMLReader
objXMLReader = new XmlTextReader(objResponseStream);

//Declare XMLDocument
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(objXMLReader);
xmldoc.Save(@"C:\Documents\Aplicacion1\Aplicacion1 \myxml.xml");

//Set XMLResponse object returned from XMLReader
XMLResponse = xmldoc;

//Close XMLReader
objXMLReader.Close();
}

//Close HttpWebResponse
objHttpWebResponse.Close();
}
catch (WebException we)
{
//TODO: Add custom exception handling
throw new Exception(we.Message);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
//Close connections
objRequestStream.Close();
objResponseStream.Close();
objHttpWebResponse.Close();

//Release objects
objXMLReader = null;
objRequestStream = null;
objResponseStream = null;
objHttpWebResponse = null;
objHttpWebRequest = null;
}

//Return
return XMLResponse;
}


Mi question now is how can I send multiple XML as parameters in one httpwebrequest?

Like:
public static XmlDocument PostXMLTransaction(xmldocument xml1, xmldocument xml2)
Oct 20 '11 #1
0 1419

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Terri | last post by:
I have form1.asp which contains a form which is posted to and processed by a page called process.asp. I want to create a second form on form2.asp and also post it to process.asp. On process.asp I...
6
by: Fabri | last post by:
Is it possible to post all (or more of one) forms simultaneosly? document.forms.submit? Any help appreciated. Regards. -- Fabri
6
by: Davie | last post by:
I want to authorise a user of a web service by using the AuthHeaderValue for some reason I keep getting a null reference exception when I try to run the following code: It seems to work fine on a...
3
by: Elroyskimms | last post by:
I know that multiple class inheritance is not possible in VB.Net I also know that I can: inherit class a and in class a: inherit class b and in class b:
1
by: raiya | last post by:
hi, I'm a teacher and new ms access user. I'm intending to design an ms access db to post multiple choice questions each with 4 choices. I created 2 tables one for the questions and the other for the...
2
jlrodrigues
by: jlrodrigues | last post by:
I have this WebService with a webmethod tha returns XML, accessed by HTTP POST... The webservice response is: <?xml version="1.0" encoding="utf-8"?> XML For XML i create a XMLDocument...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
4
by: kplkumar | last post by:
Hi I want to make calls to my webservice method multiple times using a persistent http connection. Is this possible?
1
by: loknath11 | last post by:
I have problem with posting multiple items from sel2 to database without selection.It will so kind from you if you could look my code. ///certificate.php <html> <head> <script...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.