averylongloginname has asked for the wisdom of the Perl Monks concerning the following question:

Okay, I posted a question earlier 'xml stream' that I now know did not have enough information (mainly because I did not quite fully understand the problem). I'm a little closer now so I'm going to re-word it. Here's what's happening (and I'll give more specifics here):

My webpage is used to control procurement and purchasing for a local school district (pencils, desks, computers, etc…). I am trying to integrate direct business to business transactions from our website to "SOME_VENDOR's" website where the user on my website can 'punchout' to "SOME_VENDOR" by clicking on a 'shop at SOME_VENDOR' button, do some shopping and click a 'checkout' button which will send the entire 'shopping basket' contents (in the form of an XML document) from the vendor to the 'postback_url' that I submitted to the vendor during the punchout.
All transactions are done on https
Webserver: IIS5
Perl: Latest version of Activestate.

That is it in a nutshell. Looks kind of confusing - basically, this is to cut a lot of the red tape involved in purchasing - integrating with our own procurement process thereby going through only one purchasing process instead of two.

My question is that when the user is ready to checkout, SOME_VENDOR will eventually send an XML page with the shopping basket contents to the postback_url I gave them. So I need a script that is expecting an XML page - I'm not sure how to do this. Most everything I've see on LWP involves initiating a request and parsing the response to that request, but it seems to me that the request was at the punchout page - not sure how to 'expect this XML page'.

Thanks, sorry for the lengthy text.

Replies are listed 'Best First'.
Re: xml response
by arturo (Vicar) on Jan 24, 2001 at 21:17 UTC

    What you want, then, is a CGI script that handles a file upload -- or so I understand it. That's what should be sitting at (what you call) the postback_url. The script on the vendor's site should submit the XML file as an upload (i.e. if they're using Perl, they'll use LWP to submit the XML to you; you'll handle it with (if you're sane =) CGI.pm).

    The fact that the file you're receiving is in XML format isn't *terribly* important for purposes of recieving it; what your script needs to do is handle the upload, and save the file to a designated location. Then process it (this can be handled by the CGI script itself, a script *called by* the CGI script, or maybe a cron job).

    As far as handling uploads via CGI are concerned, you can read the documentation for CGI.pm with perldoc CGI and/or entering a search for "handling uploads" and the like on this site.

    Hope that's helped you narrow down what you need to know!

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

      I don't think this is a file upload. The vendor is going to "transmit the XML in some way" to port 443 on averylongloginname's server. Without knowing exaxtly how the vendor does this, makes it difficult to know what the answer is. i.e.:

      1. Is the vendor doing a POST or GET to the URL provided?
      2. Is the vendor opening a connection to port 443 and sending a stream of data (XML)

      if (1), then what is the field name which will hold the XML. What other fieldnames are there that might be necessary?
      if (2), will there be any headers\footers that need to be stripped off?

      I suggest:
      if (1) - then use the CGI module to capture the XML from the query_string or posted data and shove it in a variable to be parsed by your preferred method.
      if (2) - then I'd suggest something like IO::Socket or HTTP::Daemon to "act" as a web server. I.e. listen on port 443 and wait for connections. See Listening on an HTTP port for some samples. But obviously this is made more difficult because you need to be able to deal with the SSL encoded data on your side.

      averylongloginname, can you give some more specific details about how the XML is being sent? You can post it here, if you start another node then it will get confusing for everyone! =)

      $code or die
      Using perl at
      The Spiders Web
Re: xml response
by averylongloginname (Novice) on Jan 25, 2001 at 21:18 UTC
    ...still trying to get back in touch with Mr. man from "BIG VENDOR", but here's a tidbit of info. When the shopping basket comes back to my web server - I have a small routine that prints out all of the environment variables.
    CONTENT_TYPE=application/x-www-form-urlencoded HTTP_REFERER=https://b2brcommpreview.us.dell.com/rcomm/b2bsendor.asp CONTENT_LENGTH=3700 SERVER_PROTOCOL=HTTP/1.1 There is no query string

    The content length appears to be correct - it increases or decreases depending on how large the order is, but where is the order hiding??

      Try reading $ENV{CONTENT_LENGTH} bytes from STDIN.

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

        POSTed content is read in through STDIN ... of course, CGI.pm handles this for you ... Try the following snippet:

        use CGI qw(:param); foreach ( param ) { print "<p>$_ : ", param($_), "</p><hr>\n"; }

        That will print out every parameter your script was passed. I bet you find an XML document in there somewhere =)

Re: xml response
by averylongloginname (Novice) on Jan 25, 2001 at 22:48 UTC
    well, guess what - it was indeed hidden in a parameter called 'cblencoded'....aaaaahhh. Talk about over analyzing a situation. Thanks for helping everyone - I'll buy ya'll a beer if your in the Austin area.

    "Homer no function beer well without"