Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLHttpRequest Object

Status
Not open for further replies.

kirthi97

Programmer
Jun 21, 2006
7
US
I have to write a code that runs on the server that posts an XML file to the given URL using XMLHttpRequest Object.

I know that I can use XMLHttpRequest Object on the client side in JavaScript to do this. But is there anyway where I can use XMLHttpRequest object on the server side which can be run as a stand alone application

Can any one give me any idea on this?

Thank You
 
from what I know javascript can not be run stand alone, it will need a browser to interperet it, I may be wrong on this one. What server side languages do you have access to on the server?

I don't know the answer but my good friend Google does.
 
The problem is that your client knows better than you and that some of your fellow members. Go googling with some keywords containing server xmlhttp.
 
On the web server using ASP you may
Code:
'Use the XMLHTTP component
Dim objHTTP, XMLString
set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")

' get the requested XML data from the remote location
' change the URL as per your feed.
objHTTP.open "GET",  "[URL unfurl="true"]http://domain/script_providing_xml",[/URL]
false

objHTTP.send

' save the XML in objXML as XML
XMLString = objHTTP.ResponseText

'And use the XMLDOM component to extract data 
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.loadXML(XMLString)
Set Root = objXMLDoc.documentElement
etc.
 
Hi Rac2...

Can I run this code as a standalone application with out browser coming into picture....

I am a Java Programmer.

I have to post an xml file using a standalone application from my company to a different company which uses XMLHTTP to get that file. So

I am trying to see like hoow this file file is posted when sent using XMLHTTP as a string or a stream so that I can create a stream in my Java program and send it out.
 
kirthi97, you posed this question before but did not answer my questions.
theniteowl said:
kirthi97, can you give more detail about the steps you are trying to take? I do not quite understand all of what you want to accomplish.

You say the XML file is on your server and you want to send it to another company. You also say though that the other company retrieves the file with XMLHTTP and XMLDOM which sounds like conflicting information to me.

Is this to be an automated process or is it going to require you to post the file from your end?

Is the file on your web server or on a file server?
If a web server, what type of server and what server-side language do you have available?

It is possible to access the file with Javascript but how depends a lot on where the file resides and what you want to do with it.

Sorry I cannot be real specific because I do not understand your particular circumstances.
If the file resides on the web server you could automate the transfer with server-side script or just make the file available for retrieval if the other company has an automated retrieval method.

There is much that I do not know about XMLHTTP but as far as I know it is for retrievig information not sending it.
You say you need to post it to another company but then you say that company retrieves it which sounds conflicting.

It sounds to me like you are trying to place a document in a location that the other company can retrieve with XMLHttpRequest and you want to automate the placement of that document for them. Is this correct?
Where is the file originating from? What do you need to do on your end before the other company retrieves the file?

Either you need to place the file on your own web server so the other company can retrieve it or you need to place the file on the other company's server. The methods used could be very different depending on which way it has to go.

As for using Javascript without a browser, you can use a .HTA file that executes with client-side permissions. It uses the same engine as Internet Explorer but without all the menu extras and allows you to design the app with HTML, Javascript and VBScript. I suspect that what you are really asking for is a way to execute code automatically without someone having to open a browser window, go to the page and do something manually. You should be able to do this with a .HTA file but you could also do it with a .VBS file using VBA/VBScript.

As others have said, your question does not make sense to us and I believe it is a misunderstanding of what the technologies you are trying to use are capable of. Give us more detail about the steps you need to perform and we can make suggestions about the best methods to accomplish them.


At my age I still learn something new every day, but I forget two others.
 
Try doing some reading on the java.net.HttpURLConnection class. Also try reading up on cron jobs.

I don't know the answer but my good friend Google does.
 
XMLHttpRequest CAN be used for sending information. It does basically the same thing your browser does: send and receive http requests.

Web page forms (and URLs with query strings) are used to send information to the server via get or post requests.

XMLHttpRequest can do the same thing. You either encode the data you want sent as a querystring in the URL, or you build a post data block and send that along with the request.



Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
You can't use XMLHttpRequest to send data outside the domain of the website (it's a restriction of the browsers I do believe). So you can't view a page on and have it send data to another site - you can only submit to
Of course, once you have submitted the data to you could then process the data server-side and forward it on to but at a server-side level.


Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Browser? where? on the server?... and believe?
 
Hello Kirthi97,

Indeed you can run the ASP code without involving a browser. It runs on the server, as does a JSP, if I understand correctly what JSP does.

Can you run it as a standalone application? We are talking about web servers and web clients using the HTTP protocol to REQUEST pages or services and to RESPOND with files, that is, with streams.

Your company computer might run a JSP script that produces an XML "document" instead of an HTML "document". I say "document" because when it comes to dynamic web pages, there really is no document as we might think of a word processing file. Just a stream of bytes that are rendered as a "document" by a browser, or parsed for pieces of data by an XML processor such as XMLDOM.

I am sure there are Java classes that can be used to generate XML documents. See the message by j4606. Or you can do it "by hand", an XML document is not a complicated thing.

As to XMLHTTP. That will be used by the other company. Or they could use other components or methods or write a Perl script to parse the stream that you send in response to their request. Whatever. That is their responsibility.

You could use XMLHTTP and XMLDOM, but those are Microsoft things and it sounds like you are a Java developer so why not use Java classes?
 
Hi all thank you very much for all suggestions. And I am really sorry for not giving you the correct info.

I have an XML file on the file server.

I have to write a program that sends this xml file to the other company using HTTP.

They gave me an URL to post my file. And this whole process has to be automated.

I have Tomcat webserver. Can I just read the XML file as a string and send it using HTTP post?

Thank you once again for the all the replies


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top