Solved

Send XML Read Xml ASP Page

Posted on 2006-11-16
8
1,785 Views
Last Modified: 2008-01-09
I have an ASP Page

Visual Studio 2005, CF2 , C#

When i call my website i have to send a bunch of XML nodes , Probably coming from an exe (VS 2005 C#).

How do i do I send the XML and how does my Web Page Read the XML?


0
Comment
Question by:Mikal613
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 35

Expert Comment

by:YZlat
ID: 17957335
send to where? read from where?
0
 
LVL 48

Author Comment

by:Mikal613
ID: 17957534
Heres the scenario

on 69.23.23.23 i have a webPage  Default.aspx

I wanna send parameters FROM 213.345.234.122 to 69.23.23.23 and it will populate the info based on the parameters.

0
 
LVL 9

Expert Comment

by:deathtospam
ID: 17957573
Mikal613 --

I just want to make sure I understand your question:

1) You have a Classic ASP page that needs to send some XML-formatted data to another website, and then interpret the XML that is returned.
2) The website that you are trying to communicate with, which is receiving the data and returning output, is running ASP.NET / C# (Visual Studio 2005).

Please tell us if this is accurate or not, so we can better assist you.


-= DeathToSpam =-
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 48

Author Comment

by:Mikal613
ID: 17957602
1)Its a desktop App that will call the web page like

69.23.23.23\MyWebPage\Default.aspx?Id=23,23,23Name=45,45,45,45

and then my webpage some how should retrieve the Id's and Names

0
 
LVL 48

Author Comment

by:Mikal613
ID: 17957606
Pref using XML
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 17988308


You will want to use the HttpWebRequest and HttpWebResponse classes to create a proxy that can read the uri streams (which, of course, will be in XML format).

The request (calling function) will look something like:



   byte[] buff = System.Text.Encoding.ASCII.GetBytes(myXML);

   HttpWebRequest myHttpRequest = (HttpWebRequest)HttpWebRequest.Create(<URL>);
   myHttpRequest.Method = "POST";
   myHttpRequest.KeepAlive = false;
   myHttpRequest.ContentType = "application/x-www-form-urlencoded";
   myHttpRequest.ContentLength = buff.Length;
   NetworkCredential cred = new NetworkCredential("user","password","myDomain");;
   CredentialCache credCache = new CredentialCache();
   credCache.Add(new Uri(serviceURI), "Basic", cred);
   myHttpRequest.Credentials = credCache;
   myHttpRequest.Timeout = 30000;
           
   HttpWebResponse myHttpResponse = null;
   string response = string.Empty;

   Stream myRequestStream = null;
   Stream baseStream = null;
   try
   {
         myRequestStream = myHttpRequest.GetRequestStream();
         myRequestStream.Write(buff,0,buff.Length);   // Sends the XML to web page - waits for response
                   
         myHttpResponse = (HttpWebResponse)myHttpRequest.GetResponse();  //  reads the response
         baseStream = myHttpResponse.GetResponseStream();
         
         XmlTextReader xmlRdr = new XmlTextReader(baseStream);
               
         xmlRdr.MoveToContent();
         response = HttpUtility.HtmlDecode(xmlRdr.ReadInnerXml());
   }

0
 
LVL 22

Expert Comment

by:_TAD_
ID: 17988309


You will want to use the HttpWebRequest and HttpWebResponse classes to create a proxy that can read the uri streams (which, of course, will be in XML format).

The request (calling function) will look something like:



   byte[] buff = System.Text.Encoding.ASCII.GetBytes(myXML);

   HttpWebRequest myHttpRequest = (HttpWebRequest)HttpWebRequest.Create(<URL>);
   myHttpRequest.Method = "POST";
   myHttpRequest.KeepAlive = false;
   myHttpRequest.ContentType = "application/x-www-form-urlencoded";
   myHttpRequest.ContentLength = buff.Length;
   NetworkCredential cred = new NetworkCredential("user","password","myDomain");;
   CredentialCache credCache = new CredentialCache();
   credCache.Add(new Uri(serviceURI), "Basic", cred);
   myHttpRequest.Credentials = credCache;
   myHttpRequest.Timeout = 30000;
           
   HttpWebResponse myHttpResponse = null;
   string response = string.Empty;

   Stream myRequestStream = null;
   Stream baseStream = null;
   try
   {
         myRequestStream = myHttpRequest.GetRequestStream();
         myRequestStream.Write(buff,0,buff.Length);   // Sends the XML to web page - waits for response
                   
         myHttpResponse = (HttpWebResponse)myHttpRequest.GetResponse();  //  reads the response
         baseStream = myHttpResponse.GetResponseStream();
         
         XmlTextReader xmlRdr = new XmlTextReader(baseStream);
               
         xmlRdr.MoveToContent();
         response = HttpUtility.HtmlDecode(xmlRdr.ReadInnerXml());
   }

0
 
LVL 22

Accepted Solution

by:
_TAD_ earned 500 total points
ID: 17988310


You will want to use the HttpWebRequest and HttpWebResponse classes to create a proxy that can read the uri streams (which, of course, will be in XML format).

The request (calling function) will look something like:



   byte[] buff = System.Text.Encoding.ASCII.GetBytes(myXML);

   HttpWebRequest myHttpRequest = (HttpWebRequest)HttpWebRequest.Create(<URL>);
   myHttpRequest.Method = "POST";
   myHttpRequest.KeepAlive = false;
   myHttpRequest.ContentType = "application/x-www-form-urlencoded";
   myHttpRequest.ContentLength = buff.Length;
   NetworkCredential cred = new NetworkCredential("user","password","myDomain");;
   CredentialCache credCache = new CredentialCache();
   credCache.Add(new Uri(serviceURI), "Basic", cred);
   myHttpRequest.Credentials = credCache;
   myHttpRequest.Timeout = 30000;
           
   HttpWebResponse myHttpResponse = null;
   string response = string.Empty;

   Stream myRequestStream = null;
   Stream baseStream = null;
   try
   {
         myRequestStream = myHttpRequest.GetRequestStream();
         myRequestStream.Write(buff,0,buff.Length);   // Sends the XML to web page - waits for response
                   
         myHttpResponse = (HttpWebResponse)myHttpRequest.GetResponse();  //  reads the response
         baseStream = myHttpResponse.GetResponseStream();
         
         XmlTextReader xmlRdr = new XmlTextReader(baseStream);
               
         xmlRdr.MoveToContent();
         response = HttpUtility.HtmlDecode(xmlRdr.ReadInnerXml());
   }

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question