473,324 Members | 1,678 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,324 software developers and data experts.

Sending a XML document via HTTP

I'm new to XML.

I need to have my asp.net page accept an XML document sent
via HTTP (from a Java app), process some info and send
back a response as XML.

I continue to get back an error on my web page:
The data at the root level is invalid. Line 1, position 1.

Currently, I am running the XML document through the class
XmlDocument (so I can read the the line <?xml
version="1.0" encoding="UTF-8">), saving it to a file on
my server then opening it with XmlTextReader to read and
process some info, and then responding back with XML.

Thanks in advance. I've been stuggling with this for a
while and would appreciate any help.

My .aspx page
<HTML>
<HEAD>
<title>Test Page</title>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<%
string strXML = doCallProcessRequest(m_strRequest);
output.InnerHtml = strXML;
%>
<font size="5" color="#02027a">Reading XML
Document</font>
<div id="output" runat="server" />
</form>
</body>
</HTML>

My Codebehind:

private void Page_Load(object sender, System.EventArgs e)
{
m_strRequest = Server.HtmlEncode
(Request.QueryString.GetValues("value")[0]);
}

public string doCallProcessRequest(string strXML)
{
//Create the XmlDocument that was passed in on the URL
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.LoadXml(strXML);

// Save the document to a file so we can use the
XmlTextReader
myXmlDocument.Save(Server.MapPath
("Files\\Request.xml"));

// retrieve UserID/Password via XMLTextReader from the
above file

// Test if a valid User
KYCSecurity objSecurity = new KYCSecurity();

bool bRet = objSecurity.IsValidUser(strUserID,
strPassword);
if (bRet)
{
// build this XML string here
string strXMLResponse="";

return strXMLResponse;
}
else
{
// Invalid UserID and/or Password
return "Invalid UserID and/or Password";
}
}
Input:
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:noNamespaceSchemaLocation="C:\_Test\Request
Message - Account.xsd" id="YYY" password="XXX"
RequestType="ADD">
<Account>
<ID>101</ID>
<AcctNum>12345</AcctNum>
<CurrencyCode>50</CurrencyCode>
<AcctName>Dummy Account Name</AcctName>
<AcctPurpose>Sample Purpose</AcctPurpose>
<AvgPaymentValue>Sample</AvgPaymentValue>
<AvgPaymentVolume>Sample</AvgPaymentVolume>
<AvgBalance>Sample</AvgBalance>
</Account>
</Request>

Output:
<?xml version="1.0" encoding="UTF-8"?>
<ResponseList xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:noNamespaceSchemaLocation="C:\_Test\Response
Message.xsd">
<Response>
<StatusList>
<Status>
<Code>5</Code>
<Description>OK</Description>
</Status>
</StatusList>
<ErrorList>
<Error>
<Code>1000</Code>
<Description>Sample Warning or
Error</Description>
</Error>
</ErrorList>
<ReturnDataList>
<ReturnData>
<Name>ID</Name>
<Value>1234567890</Value>
</ReturnData>
<ReturnData>
<Name>STATUS</Name>
<Value>Complete</Value>
</ReturnData>
</ReturnDataList>
</Response>
</ResponseList>

Nov 11 '05 #1
2 3055
Do a regular html form request and

handicraft your server acceptance.

----------

the Ms way (there is none),

otherwise will cost you (http)


"Robert" <pr*****@noemailspecified.com> wrote in message
news:3a****************************@phx.gbl...
I'm new to XML.

I need to have my asp.net page accept an XML document sent
via HTTP (from a Java app), process some info and send
back a response as XML.

I continue to get back an error on my web page:
The data at the root level is invalid. Line 1, position 1.

Currently, I am running the XML document through the class
XmlDocument (so I can read the the line <?xml
version="1.0" encoding="UTF-8">), saving it to a file on
my server then opening it with XmlTextReader to read and
process some info, and then responding back with XML.

Thanks in advance. I've been stuggling with this for a
while and would appreciate any help.

My .aspx page
<HTML>
<HEAD>
<title>Test Page</title>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<%
string strXML = doCallProcessRequest(m_strRequest);
output.InnerHtml = strXML;
%>
<font size="5" color="#02027a">Reading XML
Document</font>
<div id="output" runat="server" />
</form>
</body>
</HTML>

My Codebehind:

private void Page_Load(object sender, System.EventArgs e)
{
m_strRequest = Server.HtmlEncode
(Request.QueryString.GetValues("value")[0]);
}

public string doCallProcessRequest(string strXML)
{
//Create the XmlDocument that was passed in on the URL
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.LoadXml(strXML);

// Save the document to a file so we can use the
XmlTextReader
myXmlDocument.Save(Server.MapPath
("Files\\Request.xml"));

// retrieve UserID/Password via XMLTextReader from the
above file

// Test if a valid User
KYCSecurity objSecurity = new KYCSecurity();

bool bRet = objSecurity.IsValidUser(strUserID,
strPassword);
if (bRet)
{
// build this XML string here
string strXMLResponse="";

return strXMLResponse;
}
else
{
// Invalid UserID and/or Password
return "Invalid UserID and/or Password";
}
}
Input:
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:noNamespaceSchemaLocation="C:\_Test\Request
Message - Account.xsd" id="YYY" password="XXX"
RequestType="ADD">
<Account>
<ID>101</ID>
<AcctNum>12345</AcctNum>
<CurrencyCode>50</CurrencyCode>
<AcctName>Dummy Account Name</AcctName>
<AcctPurpose>Sample Purpose</AcctPurpose>
<AvgPaymentValue>Sample</AvgPaymentValue>
<AvgPaymentVolume>Sample</AvgPaymentVolume>
<AvgBalance>Sample</AvgBalance>
</Account>
</Request>

Output:
<?xml version="1.0" encoding="UTF-8"?>
<ResponseList xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:noNamespaceSchemaLocation="C:\_Test\Response
Message.xsd">
<Response>
<StatusList>
<Status>
<Code>5</Code>
<Description>OK</Description>
</Status>
</StatusList>
<ErrorList>
<Error>
<Code>1000</Code>
<Description>Sample Warning or
Error</Description>
</Error>
</ErrorList>
<ReturnDataList>
<ReturnData>
<Name>ID</Name>
<Value>1234567890</Value>
</ReturnData>
<ReturnData>
<Name>STATUS</Name>
<Value>Complete</Value>
</ReturnData>
</ReturnDataList>
</Response>
</ResponseList>


Nov 11 '05 #2
If you use stream object instead of string, everything should work just fine
for you. Or change the Encoding of the output document from UTF-8 to
UTF-16.

Howard Hao.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
"Robert" <pr*****@noemailspecified.com> wrote in message
news:3a****************************@phx.gbl...
I'm new to XML.

I need to have my asp.net page accept an XML document sent
via HTTP (from a Java app), process some info and send
back a response as XML.

I continue to get back an error on my web page:
The data at the root level is invalid. Line 1, position 1.

Currently, I am running the XML document through the class
XmlDocument (so I can read the the line <?xml
version="1.0" encoding="UTF-8">), saving it to a file on
my server then opening it with XmlTextReader to read and
process some info, and then responding back with XML.

Thanks in advance. I've been stuggling with this for a
while and would appreciate any help.

My .aspx page
<HTML>
<HEAD>
<title>Test Page</title>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<%
string strXML = doCallProcessRequest(m_strRequest);
output.InnerHtml = strXML;
%>
<font size="5" color="#02027a">Reading XML
Document</font>
<div id="output" runat="server" />
</form>
</body>
</HTML>

My Codebehind:

private void Page_Load(object sender, System.EventArgs e)
{
m_strRequest = Server.HtmlEncode
(Request.QueryString.GetValues("value")[0]);
}

public string doCallProcessRequest(string strXML)
{
//Create the XmlDocument that was passed in on the URL
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.LoadXml(strXML);

// Save the document to a file so we can use the
XmlTextReader
myXmlDocument.Save(Server.MapPath
("Files\\Request.xml"));

// retrieve UserID/Password via XMLTextReader from the
above file

// Test if a valid User
KYCSecurity objSecurity = new KYCSecurity();

bool bRet = objSecurity.IsValidUser(strUserID,
strPassword);
if (bRet)
{
// build this XML string here
string strXMLResponse="";

return strXMLResponse;
}
else
{
// Invalid UserID and/or Password
return "Invalid UserID and/or Password";
}
}
Input:
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:noNamespaceSchemaLocation="C:\_Test\Request
Message - Account.xsd" id="YYY" password="XXX"
RequestType="ADD">
<Account>
<ID>101</ID>
<AcctNum>12345</AcctNum>
<CurrencyCode>50</CurrencyCode>
<AcctName>Dummy Account Name</AcctName>
<AcctPurpose>Sample Purpose</AcctPurpose>
<AvgPaymentValue>Sample</AvgPaymentValue>
<AvgPaymentVolume>Sample</AvgPaymentVolume>
<AvgBalance>Sample</AvgBalance>
</Account>
</Request>

Output:
<?xml version="1.0" encoding="UTF-8"?>
<ResponseList xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:noNamespaceSchemaLocation="C:\_Test\Response
Message.xsd">
<Response>
<StatusList>
<Status>
<Code>5</Code>
<Description>OK</Description>
</Status>
</StatusList>
<ErrorList>
<Error>
<Code>1000</Code>
<Description>Sample Warning or
Error</Description>
</Error>
</ErrorList>
<ReturnDataList>
<ReturnData>
<Name>ID</Name>
<Value>1234567890</Value>
</ReturnData>
<ReturnData>
<Name>STATUS</Name>
<Value>Complete</Value>
</ReturnData>
</ReturnDataList>
</Response>
</ResponseList>

Nov 11 '05 #3

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

Similar topics

3
by: John Chen | last post by:
I need to use iframe to create a floating frame. But the contents in the iframe is not a external html file. Rather, it will be dynamically created by jsp. How can I set the src attribute to a URL...
5
by: vanisathish | last post by:
Hi All, I need to constantly update some values to the User Interface. In order to do the updation efficiently, i am planning to run some script in the server side that constantly keeps sending...
3
by: Emily John | last post by:
I have a word document that I need to send it as an attachment to an XML file. Basically, converting into byte array or using some encoding mechanism. This has to be done through XML serialization...
3
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address...
3
by: Dave | last post by:
I have a button that calls a JavaScript. I need to get the value in an asp:TextBox field to the javascript, either as a parameter or via some mechanism within the JavaScript itself. Any Ideas? ...
13
by: yawnmoth | last post by:
Say I wrote an ajax script to send out HTTP requests via ajax. Any cookies that I have associated with that site will be sent along with this HTTP request. Is there a way to prevent this from...
8
by: Amol | last post by:
Hi , I am developing a web application.I need an interface in my application which will allow the user to send the fax domestic /international.I dont want to use 3rd party tool /service .Does...
7
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of...
2
by: lstanikmas | last post by:
Hi, I'm validating a form with this ASP but receiving some blank email responses; does anyone see anything wrong with it?: function isFormVarExcluded(thisForm, strToCheck) { var strExcludeVars...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.