By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,406 Members | 2,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,406 IT Pros & Developers. It's quick & easy.

Need to post XML file to URL

P: n/a
I am trying to test a PHP script that is going to parse an XML string
to access an Informix database. I have successfully recompiled PHP
for Informix. I am running Fedora Core 3 with PHP 5.

How can for testing purposes send an XML file to my PHP program
running on Apache?

Thanks
Gary

Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Gary Quiring wrote:
How can for testing purposes send an XML file to my PHP program
running on Apache?


As a wild guess: how about trying to send it just like any other type
of file?

--
Markku Uttula

Jul 17 '05 #2

P: n/a
"Gary Quiring" <gq******@msn.com> wrote in message
news:hc********************************@4ax.com...
I am trying to test a PHP script that is going to parse an XML string
to access an Informix database. I have successfully recompiled PHP
for Informix. I am running Fedora Core 3 with PHP 5.

How can for testing purposes send an XML file to my PHP program
running on Apache?

Thanks
Gary


See http://www.php.net/stream_context_create/ . To perform a body, change
the method item to POST and put the post data in a array item keyed by
'body'.

Jul 17 '05 #3

P: n/a
On Tue, 21 Dec 2004 01:23:26 +0200, "Markku Uttula"
<ma***********@disconova.com> wrote:
Gary Quiring wrote:
How can for testing purposes send an XML file to my PHP program
running on Apache?


As a wild guess: how about trying to send it just like any other type
of file?

That would be dandy if I knew how to do that!!!!
Jul 17 '05 #4

P: n/a
Hello,

on 12/20/2004 08:46 PM Gary Quiring said the following:
I am trying to test a PHP script that is going to parse an XML string
to access an Informix database. I have successfully recompiled PHP
for Informix. I am running Fedora Core 3 with PHP 5.

How can for testing purposes send an XML file to my PHP program
running on Apache?


That depends on how you want to send the file: like a file form field or
in the body of the POST request?

Either way you can use this HTTP client class that comes with examples
of how to send files in either way.

http://www.phpclasses.org/httpclient
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #5

P: n/a
On Mon, 20 Dec 2004 19:12:23 -0500, "Chung Leong"
<ch***********@hotmail.com> wrote:
"Gary Quiring" <gq******@msn.com> wrote in message
news:hc********************************@4ax.com.. .
I am trying to test a PHP script that is going to parse an XML string
to access an Informix database. I have successfully recompiled PHP
for Informix. I am running Fedora Core 3 with PHP 5.

How can for testing purposes send an XML file to my PHP program
running on Apache?

Thanks
Gary


See http://www.php.net/stream_context_create/ . To perform a body, change
the method item to POST and put the post data in a array item keyed by
'body'.

I got it. Thank you. I have no idea what I am doing because I don't
know HTML either. But I got it working using something similiar to
what you recommended:

$xmlfile = implode('', file('xml'));

$alternate_opts = array(
'http'=>array(
'method'=>"POST",
'header'=>"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen("$xmlfile"),
'content'=>"$xmlfile"
)
);
$context = stream_context_create($alternate_opts);

$fp = fopen('http://www.testsite.com/index.php', 'r', false,
$context);
fpassthru($fp);
fclose($fp);

Thanks
Gary Quiring

Jul 17 '05 #6

P: n/a
In article <hc********************************@4ax.com>, Gary Quiring wrote:
I am trying to test a PHP script that is going to parse an XML string
to access an Informix database. I have successfully recompiled PHP
for Informix. I am running Fedora Core 3 with PHP 5.

How can for testing purposes send an XML file to my PHP program
running on Apache?


A very basic function that allows you to post stuff:
http://home.mysth.be/~timvw/programming/php/client.txt
Receiving xml:
<?php
$data = file_get_contents('php://input');
// do whatever you want to do with the data
?>
--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Jul 17 '05 #7

P: n/a
Gary Quiring wrote:
How can for testing purposes send an XML file to my PHP program
running on Apache?


As a wild guess: how about trying to send it just like any other
type
of file?


That would be dandy if I knew how to do that!!!!


Sorry. For some reason I was under the impression that you thought
something special was needed to be able to upload XML-files (in
contrast to any other file type). Information on file upload in
general can be found at
http://www.php.net/manual/en/features.file-upload.php (if that is of
any help to you).

--
Markku Uttula

Jul 17 '05 #8

P: n/a
On Tue, 21 Dec 2004 18:14:30 +0200, "Markku Uttula"
<ma***********@disconova.com> wrote:
Gary Quiring wrote:
How can for testing purposes send an XML file to my PHP program
running on Apache?

As a wild guess: how about trying to send it just like any other
type
of file?


That would be dandy if I knew how to do that!!!!


Sorry. For some reason I was under the impression that you thought
something special was needed to be able to upload XML-files (in
contrast to any other file type). Information on file upload in
general can be found at
http://www.php.net/manual/en/features.file-upload.php (if that is of
any help to you).

No problem, just a newbie with lots of OLD programming experiece. I am not used
to PHP or HTML. I have a vendor that is only sending data using XML via HTTP.
We usually do all work in FTP with UNIX and Informix 4GL. I am limping along
but it's really hard to test this stuff.

Gary
Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.