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)