M
Maris Janis Vasilevskis
Hi,
Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does?
More details. I port JScript to JScript.NET
I have a server (ASP invoking binary code; code not accessible).
I send XML requests to it.
If my request is accepted, ServerXMLHTTP returns XML with accept details.
If my request is rejected, ServerXMLHTTP returns XML with reject details.
ServerXMLHTTP always returns XML.
For accepted requests, HttpWebRequest returns the same as ServerXMLHTTP.
But for rejected requests, HttpWebRequest fails with (500) Internal Server Error.
My JScript:
function GetResponse(xmltext) {
var xmlhttp, res;
xmlhttp = new ActiveXObject("MSXML2.ServerXMLHTTP");
xmlhttp.open( "POST", MyUrl, false );
xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
xmlhttp.send( xmltext );
res = xmlhttp.responseText;
xmlhttp = null;
return res;
}
My JScript.NET:
static public function GetResponse(xmltext:String):String {
var req:HttpWebRequest;
var rsp:HttpWebResponse;
var wr:StreamWriter;
var rd:StreamReader;
var res:String;
req=HttpWebRequest(WebRequest.Create(MyUrl));
req.Method='POST';
req.ContentType='text/xml';
wr=new StreamWriter(req.GetRequestStream());
try { wr.Write(xmltext); } finally { wr.Close(); }
rsp = HttpWebResponse(req.GetResponse()); // Possible Exception 500 here !!
rd=new StreamReader(rsp.GetResponseStream());
res=rd.ReadToEnd();
rd.Close();
return res;
}
I played also with Credentials, ContentLength and StreamWriter Encoding, without success.
Thank you,
Mahris
Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does?
More details. I port JScript to JScript.NET
I have a server (ASP invoking binary code; code not accessible).
I send XML requests to it.
If my request is accepted, ServerXMLHTTP returns XML with accept details.
If my request is rejected, ServerXMLHTTP returns XML with reject details.
ServerXMLHTTP always returns XML.
For accepted requests, HttpWebRequest returns the same as ServerXMLHTTP.
But for rejected requests, HttpWebRequest fails with (500) Internal Server Error.
My JScript:
function GetResponse(xmltext) {
var xmlhttp, res;
xmlhttp = new ActiveXObject("MSXML2.ServerXMLHTTP");
xmlhttp.open( "POST", MyUrl, false );
xmlhttp.setRequestHeader( "Content-Type", "text/xml" );
xmlhttp.send( xmltext );
res = xmlhttp.responseText;
xmlhttp = null;
return res;
}
My JScript.NET:
static public function GetResponse(xmltext:String):String {
var req:HttpWebRequest;
var rsp:HttpWebResponse;
var wr:StreamWriter;
var rd:StreamReader;
var res:String;
req=HttpWebRequest(WebRequest.Create(MyUrl));
req.Method='POST';
req.ContentType='text/xml';
wr=new StreamWriter(req.GetRequestStream());
try { wr.Write(xmltext); } finally { wr.Close(); }
rsp = HttpWebResponse(req.GetResponse()); // Possible Exception 500 here !!
rd=new StreamReader(rsp.GetResponseStream());
res=rd.ReadToEnd();
rd.Close();
return res;
}
I played also with Credentials, ContentLength and StreamWriter Encoding, without success.
Thank you,
Mahris