Need to post XML file to URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary Quiring

    Need to post XML file to URL

    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

  • Markku Uttula

    #2
    Re: Need to post XML file to URL

    Gary Quiring wrote:[color=blue]
    > How can for testing purposes send an XML file to my PHP program
    > running on Apache?[/color]

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

    --
    Markku Uttula

    Comment

    • Chung Leong

      #3
      Re: Need to post XML file to URL

      "Gary Quiring" <gquiring@msn.c om> wrote in message
      news:hcles0pov4 r2ncftjr9lht7oa 364ljg4is@4ax.c om...[color=blue]
      > 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
      >[/color]

      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'.



      Comment

      • Gary Quiring

        #4
        Re: Need to post XML file to URL

        On Tue, 21 Dec 2004 01:23:26 +0200, "Markku Uttula"
        <markku.uttula@ disconova.com> wrote:
        [color=blue]
        >Gary Quiring wrote:[color=green]
        >> How can for testing purposes send an XML file to my PHP program
        >> running on Apache?[/color]
        >
        >As a wild guess: how about trying to send it just like any other type
        >of file?[/color]
        That would be dandy if I knew how to do that!!!!


        Comment

        • Manuel Lemos

          #5
          Re: Need to post XML file to URL

          Hello,

          on 12/20/2004 08:46 PM Gary Quiring said the following:[color=blue]
          > 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?[/color]

          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.




          --

          Regards,
          Manuel Lemos

          PHP Classes - Free ready to use OOP components written in PHP
          Free PHP Classes and Objects 2025 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


          PHP Reviews - Reviews of PHP books and other products


          Metastorage - Data object relational mapping layer generator

          Comment

          • Gary Quiring

            #6
            Re: Need to post XML file to URL

            On Mon, 20 Dec 2004 19:12:23 -0500, "Chung Leong"
            <chernyshevsky@ hotmail.com> wrote:
            [color=blue]
            >"Gary Quiring" <gquiring@msn.c om> wrote in message
            >news:hcles0pov 4r2ncftjr9lht7o a364ljg4is@4ax. com...[color=green]
            >> 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
            >>[/color]
            >
            >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'.
            >
            >[/color]
            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'=>"Cont ent-type: application/x-www-form-urlencoded\r\n" .
            "Content-length: " . strlen("$xmlfil e"),
            'content'=>"$xm lfile"
            )
            );
            $context = stream_context_ create($alterna te_opts);

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

            Thanks
            Gary Quiring

            Comment

            • Tim Van Wassenhove

              #7
              Re: Need to post XML file to URL

              In article <hcles0pov4r2nc ftjr9lht7oa364l jg4is@4ax.com>, Gary Quiring wrote:[color=blue]
              > 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?[/color]

              A very basic function that allows you to post stuff:



              Receiving xml:
              <?php
              $data = file_get_conten ts('php://input');
              // do whatever you want to do with the data
              ?>


              --
              Met vriendelijke groeten,
              Tim Van Wassenhove <http://www.timvw.info>

              Comment

              • Markku Uttula

                #8
                Re: Need to post XML file to URL

                Gary Quiring wrote:[color=blue][color=green][color=darkred]
                >>> How can for testing purposes send an XML file to my PHP program
                >>> running on Apache?[/color]
                >>
                >> As a wild guess: how about trying to send it just like any other
                >> type
                >> of file?[/color]
                >
                > That would be dandy if I knew how to do that!!!![/color]

                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

                Comment

                • Gary Quiring

                  #9
                  Re: Need to post XML file to URL

                  On Tue, 21 Dec 2004 18:14:30 +0200, "Markku Uttula"
                  <markku.uttula@ disconova.com> wrote:
                  [color=blue]
                  >Gary Quiring wrote:[color=green][color=darkred]
                  >>>> 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?[/color]
                  >>
                  >> That would be dandy if I knew how to do that!!!![/color]
                  >
                  >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).[/color]
                  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


                  Comment

                  Working...