Example for XML communication via HTTP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mihalka
Forum Newbie
Posts: 10
Joined: Thu Oct 13, 2005 2:19 pm

Example for XML communication via HTTP

Post by mihalka »

Dear all,

I'm an absolutely beginner with an intentionto write a demo php with xml / http. The task is sending XML reuests via HTTP (from a PHP script) to on other server and receiving XML response. The request data will be collected from a form and the response data (a list of http refeences).

Is there an example with similray functionality ?

I'll be very happy to start from this level.

Warm regards,

Laszlo
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

Quick question, do you mean AJAX? (Asynchronous Javascript and XML) XMLHttpRequest?
mihalka
Forum Newbie
Posts: 10
Joined: Thu Oct 13, 2005 2:19 pm

Post by mihalka »

Hello Chrys,

I checked quikly ajax, but I'm not sure if it is applicable. The server with XML engine don't use XMLHttpRequest. The XML request hav to be sent to an *.jsp. To have an asnychron communication is nice to have, but not required: the input form is placed in a html frame. Further the request should be sent from the PHP Server to an other, Tomcat server. The XML request ist not the only communication, from the same script will be accessed a MS SQL Database and finally both data (XML Response + SQL Query result) joined and displayed.

Warm regards,
Laszlo
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

If I u nderstand correctly, you want to make a request to another server through HTTP and receive a response in XML, which you can take in by a PHP script and output it on your site?
mihalka
Forum Newbie
Posts: 10
Joined: Thu Oct 13, 2005 2:19 pm

Post by mihalka »

Exactly !
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

How does the other server take requests through HTTP? Can you send any variables? Or.. is it always going to be the same XML file?
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

You can't use XMLHttpRequest to communicate with a third party server.
anubis
Forum Newbie
Posts: 5
Joined: Thu Oct 13, 2005 5:05 pm

same question

Post by anubis »

i'm actually trying to find an answer for same question as mihalka.

I posted a topic "accessing header content" earlier, didn't see this thread....my bad!!

is there a way after making a post using a standard html post to access response made by target server??...i.e. to read the http header content response.

for e.g. in CF 7 you can access this through
http(url).get("Filecontent)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You can use http://www.php.net/curl...


There was a day i didn't have curl available, so i wrote a little function that could post XML to a webservice:

http://timvw.madoka.be/programming/php/client.txt

And i also wrote a function that could recieve XML that was posted:

http://timvw.madoka.be/programming/php/service.txt
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post by jwalsh »

Feyd,

That is truely awesome... Is there ANYTHING you don't know?!

:)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

me? Hi, I'm feyd, he's Tim. That's Larry... over there is Curly.. Moe's in the John...
mihalka
Forum Newbie
Posts: 10
Joined: Thu Oct 13, 2005 2:19 pm

Post by mihalka »

Chrys: the XML communication runs as HTTPServletRequest / HTTPServletResponse. The HTTP Server doesn't evaulate HTTP Header variables. It can only set Header variables (if required), but only with "static" values like user informations. There is also no way change the functionality, because the Server is a product, not a project result.
Post Reply