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 2 8758
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
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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.
|
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.
|
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"
|
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
| |
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")
|
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 :
|
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> " &
|
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"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |