Last post Sep 14, 2014 09:00 AM by bradley82
Sep 08, 2014 03:27 PM|bradley82|LINK
I've been banging my head against a wall for days trying to make this work. I hope someone can shed some light for me. What c# objects should I be using???
var usg = template.XMLDocument
usg.async = false;
usg.preserveWhiteSpace = false;
var httpOb = new ActiveXObject("Microsoft.XMLHTTP");
httpOb.Open("POST", usgAddr, false);
The BuildELS Function just populates the XML document elements from a form (which I'm getting rid of.)
One problem I'm having is that I need this to happen server side and work on a wide variety of browser platforms (the .htm page that I'm trying to replace with .aspx is calling an activeXObject which introduces a lot of browser issues for me on various platforms).
Here is the XML data to be sent:
<USG COMMAND="USER_ADD" MAC_ADDR="">
Where MAC_ADDRESS = Request.QueryString("MA"), and PAYMENT_METHOD="600". All the other elements are blank.
Sep 08, 2014 05:38 PM|bradley82|LINK
I've got the document loaded as XmlDocument and can place the contents to a text box (to verify the XmlDocument is storing a valid, well formed XML), and it is. However, when I try to place the data in the Stream and send it, the server just times out.
protected void Button1_Click(object sender, EventArgs e)
string xmlString = "<USG COMMAND=\"USER_ADD\" MAC_ADDR=\"14DAE93E0BD8\"><USER_NAME>test1</USER_NAME><PASSWORD ENCRYPT=\"FALSE\"></PASSWORD><IP_TYPE></IP_TYPE><EXPIRY_TIME UNITS=\"SECONDS\"></EXPIRY_TIME><ROOM_NUMBER></ROOM_NUMBER><PAYMENT_METHOD>ROOM_OPEN</PAYMENT_METHOD><CONFIRMATION></CONFIRMATION><PAYMENT></PAYMENT></USG>";
string url = "http://[IP_ADDRESS]/usg/command.xml";
XmlDocument doc = new XmlDocument();
TextBox1.Text = doc.InnerXml;
HttpWebRequest httpWebRequest = null;//Declare an HTTP-specific implementation of the WebRequest class.
HttpWebResponse httpWebResponse = null;//Declare an HTTP-specific implementation of the WebResponse class
httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
bytes = System.Text.Encoding.ASCII.GetBytes(doc.InnerXml);
//Set HttpWebRequest properties
httpWebRequest.Method = "POST";
httpWebRequest.ContentLength = bytes.Length;
httpWebRequest.ContentType = "text/xml; encoding='utf-8'";
using (Stream requestStream = httpWebRequest.GetRequestStream())
//Writes a sequence of bytes to the current stream
requestStream.Write(bytes, 0, bytes.Length);
Sep 10, 2014 03:18 AM|George Hua - MSFT|LINK
If you want to perform this action on server-side, I would suggest using back end code such as C#.
Sep 14, 2014 09:00 AM|bradley82|LINK
vs posted c#). Something was failing and I was trying to determine why. I actually got the code working myself. I was surprised when I got no decent qualified response between 3 different forums. In any case, thanks anyway.