Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XMLHTTPRequest vs HTTPWebRequest

561 views
Skip to first unread message

Yazid Arezki

unread,
Oct 23, 2001, 2:32:24 PM10/23/01
to
Hello

I have used XMLHTTPREQUEST in my previous projects and I would like to
implement the same idea in .NET. I guess the equivalent of it is to use
HTTPWebRequest, the only article I have come accross is the one that
appeared in MSDN magazine (September issue). I could not get it to work, has
anybody implemented it and would like to share their experience.

TIA

Yaz

Chris Lovett

unread,
Oct 23, 2001, 1:58:33 PM10/23/01
to
The attached code sample shows you how to do this. The example sends a
find_business request to the UDDI web service and displays the returned
message. On the command line, pass the uddi.xml file and the name and port
of your proxy server (if any).. For example:
xmlhttp uddi.xml myproxy:80

"Yazid Arezki" <yals...@blueyonder.co.uk> wrote in message
news:umgs526WBHA.2048@tkmsftngp07...

uddi.xml
xmlhttp.cs

Yazid Arezki

unread,
Oct 25, 2001, 10:20:05 AM10/25/01
to
Thanks Chris,

My question was more how would I get the following to work in .NET.

<SCRIPT Language="javascript">
getDetails()
{
var strURL = http://localhost/Test/Details.aspx;
var oHTTP = new ActivexObject("MSXML2.XMLHTTP");
oHTTP.open('GET', strURL,false);
oHTTP.send();
rowTest.InnerHTML = oHTTP.responseXML;
}
</SCRIPT>
<HTML>
...

</HTML>


TIA

Yaz


"Chris Lovett" <clo...@nospam.com> wrote in message
news:3bd5afcd$1...@news.microsoft.com...

Fabrice PIERRE

unread,
Oct 26, 2001, 7:07:53 AM10/26/01
to
Hello,

I have also used XMLHTTPREQUEST in my previous project.
The client side was a VB COM object to submit to an asp (iis4/iis5) page
unicode xml string.

I am trying to move my VB COM object client to the .net world.
With the following code below. This is working fine with ASCII, so this
may help you to solve your move.

BUT I get errors when I try to work with unicode characteres, the server
side of code is not able to read
correctly the datas from the incoming stream.

Any ideas

// Client Code
string XMLString = "<?xml version=\"1.0\" ?><foo></foo>" ;
System.Uri uriObj = new System.Uri(http://xx/yy.asp);
httpRequest = (HttpWebRequest)WebRequest.CreateDefault(uriObj);
httpRequest.Method = "POST";
httpRequest.ContentType = "text/xml";
httpRequest.Credentials = new System.Net.NetworkCredential("","");
httpRequest.Accept = "*/*";
httpRequest.Headers.Add("Cache-Control","no-cache");
httpRequest.Timeout = 5000;
int BufferSize = 0;
byte[] Buffer = null;

// ASCII
httpRequest.ContentLength = XMLString.Length;
StreamWriter streamw = new
StreamWriter(httpRequest.GetRequestStream(),Encoding.ASCII);
streamw.Write(XMLString);
streamw.Close();

// UNICODE
/*
Buffer = Encoding.Unicode.GetBytes(XMLString);
httpRequest.ContentLength = Buffer.Length;
Stream wreqStream = httpRequest.GetRequestStream();
wreqStream.Write(Buffer, 0, Buffer.Length);
wreqStream.Close();
*/


HttpWebResponse lgResponse = (HttpWebResponse)httpRequest.GetResponse();
Stream stream = lgResponse.GetResponseStream();
BufferSize = (int)httpRequest.ContentLength*3;
Buffer = new byte[BufferSize];
int BytesRead = stream.Read(Buffer, 0, BufferSize);
string Answer = "";
while (BytesRead != 0)
{
Answer += Encoding.Unicode.GetString(Buffer, 0, BytesRead);
BytesRead = stream.Read(Buffer, 0, BufferSize);
}

// Server Side code
<%@Language="VbScript" %>
<%
SET docReceived = Server.CreateObject("Microsoft.XMLDOM")

docReceived.async = False
docReceived.load Request

strDoc docReceived.xml
strDoc = "<?xml version='1.0' encoding='UTF-16'?>" & strDoc
Response.BinaryWrite strDoc
SET docReceived = nothing
response.End
%>

"Yazid Arezki" <yals...@blueyonder.co.uk> wrote in message
news:umgs526WBHA.2048@tkmsftngp07...

0 new messages