473,809 Members | 2,780 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to POST multiple xml to a WebService

1 New Member
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 PostXMLTransact ion(string v_strURL)
{
//Declare XMLResponse document
XmlDocument XMLResponse = null;

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

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

//Declare a generic view of a sequence of bytes
Stream objRequestStrea m = null;
Stream objResponseStre am = null;

//Declare XMLReader
XmlTextReader objXMLReader;

//Creates an HttpWebRequest for the specified URL.
objHttpWebReque st = (HttpWebRequest )WebRequest.Cre ate(v_strURL);

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

//Set HttpWebRequest properties
byte[] bytes;
bytes = System.Text.Enc oding.UTF8.GetB ytes("C:\\Docum ents\\Aplicacio n1\\Aplicacion1 \\absisSIHttpPr ofileTO.xml");
objHttpWebReque st.Method = "POST";
objHttpWebReque st.ContentLengt h = bytes.Length;
objHttpWebReque st.ContentType = "text/xml; encoding='utf-8'";

//Get Stream object
objRequestStrea m = objHttpWebReque st.GetRequestSt ream();

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

//Close stream
objRequestStrea m.Close();

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

//Sends the HttpWebRequest, and waits for a response.
objHttpWebRespo nse = (HttpWebRespons e)objHttpWebReq uest.GetRespons e();

//---------- Start HttpResponse
if (objHttpWebResp onse.StatusCode == HttpStatusCode. OK)
{
//Get response stream
objResponseStre am = objHttpWebRespo nse.GetResponse Stream();

//Load response stream into XMLReader
objXMLReader = new XmlTextReader(o bjResponseStrea m);

//Declare XMLDocument
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(obj XMLReader);
xmldoc.Save(@"C :\Documents\Apl icacion1\Aplica cion1\myxml.xml ");

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

//Close XMLReader
objXMLReader.Cl ose();
}

//Close HttpWebResponse
objHttpWebRespo nse.Close();
}
catch (WebException we)
{
//TODO: Add custom exception handling
throw new Exception(we.Me ssage);
}
catch (Exception ex)
{
throw new Exception(ex.Me ssage);
}
finally
{
//Close connections
objRequestStrea m.Close();
objResponseStre am.Close();
objHttpWebRespo nse.Close();

//Release objects
objXMLReader = null;
objRequestStrea m = null;
objResponseStre am = null;
objHttpWebRespo nse = null;
objHttpWebReque st = null;
}

//Return
return XMLResponse;
}


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

Like:
public static XmlDocument PostXMLTransact ion(xmldocument xml1, xmldocument xml2)
Oct 20 '11 #1
0 1440

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

Similar topics

2
2441
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 would execute different stored procedures conditionally based on where the form is submitted from. How can I tell which page the form is submitted from? I think I should be able to have a hidden form field on my forms and post that to...
6
7670
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
768
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 .NET Framework application, but just not on the .NET CF version. Can anyone suggest anything that might be wrong with the code? (I could post the app and webservice, but i was hoping that you might have noticed something from the supplied...
3
3052
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
5067
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 answers. The first has the fields: question_no - number question - text answer - memo --- gives the full solution The second has the fields: question_no - number answer_no - number answer - text t/f - text --- if this is the correct...
2
1278
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 into whom i load this string:
6
3993
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 string UID; public string PWD; }
4
3253
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
2215
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 type="text/javascript" src="stmenu.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form method ="post" action="databasensert.php" enctype="multipart/form-data">
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
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
10387
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
10120
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...
0
9200
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
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
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.