Re: Convert .net xmlhttp code to vbs




"cross" <cross@xxxxxxxxxx> wrote in message
news:eIxxEO2WHHA.4632@xxxxxxxxxxxxxxxxxxxxxxx
Can you please help me to finish converting the .net code below into
vbscript?

My vbs function at the end works when posting to another asp file on the
same win server,
but I need to post the xml to a .jsp file on a unix box. The jsp file just
returns an internal server error. It crashes with a null pointer exception
when trying to read the request. Presumably because it is not in an ascii
byte array?
How do I do those parts?

If it is too complex, then let me know and I will use the .NET code as a
relay. I would just prefer to have it all in one file.


.NET CODE
=========
// create a web request and set the method of the request to POST
HttpWebRequest request = (HttpWebRequest)
HttpWebRequest.Create(requestLocation);
request.Method = "POST";

// encode the data and store the byte representation in an array
ASCIIEncoding encoding = new ASCIIEncoding();
string postdata="xml="+HttpUtility.UrlEncode(xmlDoc);
// string postdata="xml="+xmlDoc; byte[] requestData =
encoding.GetBytes(postdata);

// set the content type of the data being posted.
request.ContentType="application/x-www-form-urlencoded";

// set the content length of the string being posted
request.ContentLength = postdata.Length;

// Status.Text += "Submitting activity message";

Stream requestStream = request.GetRequestStream();
requestStream.Write(requestData,0,requestData.Length);

// flush out the data to the underlying stream and close it
requestStream.Flush();
requestStream.Close();

// retrieve the response from the web server
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
StreamReader responseData = new
StreamReader(response.GetResponseStream());
err+= responseData.ReadToEnd();


MY VBS CODE
===========
Function iXMLPostSTX(STX_URL, POXMLData, ByRef XMLResp)

Dim oHttp
Set oHttp = Server.CreateObject ("MSXML2.ServerXMLHTTP")
Dim status

oHttp.open "POST", STX_URL
oHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHttp.setRequestHeader "Connection", "Keep-Alive"
oHttp.send POXMLData
status = oHttp.statusText
iLog("Status=" & status)

XMLResp = oHttp.responseText

End Function

It's unclear what the data type POXMLData is but I'll assume it's a string.

oHttp.send "xml=" & Server.URLEncode(POXMLData)

However, if you have control over the content of the JSP then why not simply
send the XML raw as an "text/xml" content type?


.



Relevant Pages

  • Re: Recordset.Open Causes Lockup/Timeout
    ... Thanks for the tip on the responseXML property. ... // when the request comes from the same server ... This problem is only occuring on my web host's server where direct machine access is ... This works great for server side xml requests ...
    (microsoft.public.inetserver.asp.db)
  • Re: design choice: multi-threaded / asynchronous wxpython client?
    ... is definitely time of server response to my request and bears no ... relation to when the live XML data was updated. ... It looks like the data is dynamically generated on the server, ... then re-request the doc (a download resume is risky, ...
    (comp.lang.python)
  • Re: HTTPWebRequest - GetResponse throws exception
    ... It is difficult to guess the reason for the exception by just looking at the ... and HttpWebRequest is choking on it. ... Can you get a network sniff of the POST request & response from the server? ...
    (microsoft.public.dotnet.framework)
  • Access to path denied
    ... I am running Windows 2003 Server with Framework ... that allows me to configure these XML files in the main applicaiton. ... the current web request. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: Persistent https session?
    ... This is the reply I get from the server: ... As mentioned before I get this response every time the request is made. ... I then add this certificate to the HttpWebRequest ...
    (microsoft.public.dotnet.languages.csharp)