473,804 Members | 3,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MSXML2.ServerXM LHTTP to HttpWebRequest: Error 500

Hi,

Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXM LHTTP 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(xml text) {
var xmlhttp, res;
xmlhttp = new ActiveXObject(" MSXML2.ServerXM LHTTP");
xmlhttp.open( "POST", MyUrl, false );
xmlhttp.setRequ estHeader( "Content-Type", "text/xml" );
xmlhttp.send( xmltext );
res = xmlhttp.respons eText;
xmlhttp = null;
return res;
}

My JScript.NET:
static public function GetResponse(xml text:String):St ring {
var req:HttpWebRequ est;
var rsp:HttpWebResp onse;
var wr:StreamWriter ;
var rd:StreamReader ;
var res:String;
req=HttpWebRequ est(WebRequest. Create(MyUrl));
req.Method='POS T';
req.ContentType ='text/xml';
wr=new StreamWriter(re q.GetRequestStr eam());
try { wr.Write(xmltex t); } finally { wr.Close(); }
rsp = HttpWebResponse (req.GetRespons e()); // Possible Exception 500 here !!
rd=new StreamReader(rs p.GetResponseSt ream());
res=rd.ReadToEn d();
rd.Close();
return res;
}
I played also with Credentials, ContentLength and StreamWriter Encoding, without success.

Thank you,
Mahris
Nov 19 '05 #1
2 8760
Hold on, if the request is rejected - what do you want to happen?

It doesn't sound unreasonable to have code to handle errors that may be
coming back from the server.

"Maris Janis Vasilevskis" <ma****@myself. com> wrote in message
news:eD******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Is it possible to force HttpWebRequest to do exactly (not approximately)
the same as MSXML2.ServerXM LHTTP 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(xml text) {
var xmlhttp, res;
xmlhttp = new ActiveXObject(" MSXML2.ServerXM LHTTP");
xmlhttp.open( "POST", MyUrl, false );
xmlhttp.setRequ estHeader( "Content-Type", "text/xml" );
xmlhttp.send( xmltext );
res = xmlhttp.respons eText;
xmlhttp = null;
return res;
}

My JScript.NET:
static public function GetResponse(xml text:String):St ring {
var req:HttpWebRequ est;
var rsp:HttpWebResp onse;
var wr:StreamWriter ;
var rd:StreamReader ;
var res:String;
req=HttpWebRequ est(WebRequest. Create(MyUrl));
req.Method='POS T';
req.ContentType ='text/xml';
wr=new StreamWriter(re q.GetRequestStr eam());
try { wr.Write(xmltex t); } finally { wr.Close(); }
rsp = HttpWebResponse (req.GetRespons e()); // Possible Exception 500 here
!!
rd=new StreamReader(rs p.GetResponseSt ream());
res=rd.ReadToEn d();
rd.Close();
return res;
}
I played also with Credentials, ContentLength and StreamWriter Encoding,
without success.

Thank you,
Mahris

Nov 19 '05 #2
Thank you, Marina.
However, I cannot hold on, I need to analyze the reject message.

But I found the reason.
In the server trace I see that 500 is generated for both, ServerXMLHTTP and HttpWebRequest,
together with a good XML.
Simply, ServerXMLHTTP returns the result but HttpWebRequest throws error.

So, my current solution:
static public function GetResponse(xml text:String):St ring {
var req:HttpWebRequ est;
var rsp:HttpWebResp onse;
var wr:StreamWriter ;
var rd:StreamReader ;
var res:String;
req=HttpWebRequ est(WebRequest. Create(cst.Soap URL));
req.Method='POS T';
req.ContentType ='text/xml';
wr=new StreamWriter(re q.GetRequestStr eam());
try { wr.Write(xmltex t); } finally { wr.Close(); }
try {
rsp = HttpWebResponse (req.GetRespons e());
}
catch(e:System. Net.WebExceptio n) {
if(e.Status==Sy stem.Net.WebExc eptionStatus.Pr otocolError) {
rsp = HttpWebResponse (e.Response);
}
else throw e;
}
rd=new StreamReader(rs p.GetResponseSt ream());
res=rd.ReadToEn d();
rd.Close();
return res;
}

Mahris

Marina wrote:
Hold on, if the request is rejected - what do you want to happen?

It doesn't sound unreasonable to have code to handle errors that may be
coming back from the server.

"Maris Janis Vasilevskis" <ma****@myself. com> wrote in message
news:eD******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi,

Is it possible to force HttpWebRequest to do exactly (not approximately)
the same as MSXML2.ServerXM LHTTP 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.
ServerXMLHT TP always returns XML.

For accepted requests, HttpWebRequest returns the same as ServerXMLHTTP.
But for rejected requests, HttpWebRequest fails with (500) Internal Server
Error.

Nov 19 '05 #3

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

Similar topics

3
12462
by: Dan Sikorsky | last post by:
Uploading from browser to server using Msxml2.XMLHTTP takes a long time about 15 minutes for a 1.5MB file at 37.2Kbps, although it does get there. Is there anyway to speed things up? here's the code ... var sFilename = (document.form1.myFileName.value); // create ADO-stream Object var ado_stream = new ActiveXObject("ADODB.Stream"); // create XML document with default header and primary node
0
1600
by: P1ayboy | last post by:
Trying to use Dim objXmlHttp = Server.HttpWebRequest("Msxml2.ServerXMLHTTP.4.0") in a vb.net web application on server 2003, but receive the following error. "System.Web.HttpException: Could not create an object of type 'Msxml2.ServerXMLHTTP.4.0'." Its driving me nuts and need to solve it by Monday.
1
14698
by: ehilario | last post by:
Hello everyone, I am trying to access a webservice to post some values via MSXML2.ServerXMLHttp The OS used is win2003 on both machines. When I access the local machine (A) which has the same service the call works great. When I access the other machine (B) that is on the same subnet, I get a Status of 500.
5
17894
by: katrinaVictim | last post by:
Question: I get the eror listed at the bottom of the post. What can I do to make the response of the x1.send a "binary" type? Or, in general, how can I just "make this work"? <%@ Language=VBScript %> <% Response.Buffer = TRUE Response.ContentType = "image/jpg"
2
21818
by: Michael Christensen | last post by:
Hi How do I send an input-param to my web service with MSXML2.ServerXMLHTTP? Can this be done without the soap-toolkit? Can't find anything about it - looking forward getting some help :-) ------------- Function GetLatest() Dim url, xmlhttp, XMLDOM, XMLNode
1
6593
by: Raúl Martín | last post by:
I´ve a function in asp that run correctly but If I tried to change it forasp.net in asp: xmlHTTP = CreateObject("Microsoft.XMLHTTP") And I thought to use this sentence for asp.net but the server don´t response right. xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
4
18018
by: Arnaud | last post by:
Hi, I'm trying to translate an asp application, i have some difficulties with a particular line : --- Set myxml = Server.CreateObject("Msxml2.ServerXMLHTTP.4.0") --- Classical ajax exemples rather use :
4
7682
by: s_m_b | last post by:
Using w2k advanced server (test system is standard server) "Set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument") objXML.async = False objXML.setProperty "ServerHTTPRequest", True objXML.Load ("http://news.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss091.xml") If objXML.parseError.errorCode <> 0 Then 'Response.Write "<pre>" & vbCrLf Response.Write ("<strong>Error:</strong> " &
1
2878
by: niklang | last post by:
Hi everybody, I have an ASP page that uses the MSXML2.ServerXMLHTTP object to read a stylesheet from IIS as follows: strXSLPath = "http://localhost/ej/ejdetail.xsl.asp" Dim oXMLHttpStyle Set oXMLHttpStyle = Server.CreateObject("MSXML2.ServerXMLHTTP") oXMLHttpStyle.open "GET", strXSLPath, False oXMLHttpStyle.setRequestHeader "Content-Type", "text/xml"
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10320
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.