HELP! transferring this short .asp-script to php....

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

    #1

    HELP! transferring this short .asp-script to php....

    dear all,

    i got this script form a customer. in general, it recieves data which is send
    via http to a server and generates a .xml file from this data.

    because i'm not familar with .asp, i'm totally lost transferring this script
    to php. i don't understand which way the data is recieved and how it's saved.


    as long this ia a very short script, i post it here. it would bne GREAT if
    someone could give me some tipps on how to migrate this whole thing to PHP
    and how it recieves the data via http.

    thanks a lot in advance,
    dino

    ---------- [SCRIPT START] -----------

    <%
    dim objXML
    dim lngRet

    set objXML = Server.CreateOb ject("MSXML2.Fr eeThreadedDOMDo cument.4.0")

    on error resume next

    ' set basic XML parser settings
    objXML.Async = False
    ' optional beide Werte auf true
    objXML.Validate OnParse = False
    objXML.resolveE xternals = False

    Response.Expire s = -1000

    ' V3.0(+) of XML parser allows loading of the Request object
    lngRet = objXML.Load(Req uest)
    if lngRet = True then
    call objXML.Save(Ser ver.MapPath("La stReceivedDocum ent.xml"))

    response.write "<cXML><Respons e>" & _
    "<Status code=" & chr(34) & "200" & chr(34) & " text=" &
    chr(34) & "OK" & chr(34) & "/>" & _
    "</Response>" & _
    "</cXML>"
    else
    response.write "<cXML><Respons e><Status code='404' text='Error loading
    XML'></Status></Response></cXML>"
    end if

    set objXML = nothing
    %>

    ---------- [SCRIPT END] -----------

  • Treefrog

    #2
    Re: HELP! transferring this short .asp-script to php....

    Dino wrote:[color=blue]
    > dear all,
    >
    > i got this script form a customer. in general, it recieves data which is send
    > via http to a server and generates a .xml file from this data.
    >
    > because i'm not familar with .asp, i'm totally lost transferring this script
    > to php. i don't understand which way the data is recieved and how it's saved.
    >
    > ---------- [SCRIPT START] -----------
    >
    > <%
    > dim objXML
    > dim lngRet[/color]
    // declaring vars, ignore, you don't need to in PHP, although you
    perhaps should.[color=blue]
    >
    > set objXML = Server.CreateOb ject("MSXML2.Fr eeThreadedDOMDo cument.4.0")[/color]
    // ignore, this is creating an object which isn't available in PHP.
    Perhaps use simpleXML
    [color=blue]
    > on error resume next
    >
    > ' set basic XML parser settings
    > objXML.Async = False
    > ' optional beide Werte auf true
    > objXML.Validate OnParse = False
    > objXML.resolveE xternals = False
    >
    > Response.Expire s = -1000[/color]
    // ignore all of the above.[color=blue]
    >
    > ' V3.0(+) of XML parser allows loading of the Request object
    > lngRet = objXML.Load(Req uest)[/color]
    // build an XML object based on the request data... see below for my
    comments about that
    [color=blue]
    > if lngRet = True then
    > call objXML.Save(Ser ver.MapPath("La stReceivedDocum ent.xml"))
    >
    > response.write "<cXML><Respons e>" & _
    > "<Status code=" & chr(34) & "200" & chr(34) & " text=" &
    > chr(34) & "OK" & chr(34) & "/>" & _
    > "</Response>" & _
    > "</cXML>"
    > else
    > response.write "<cXML><Respons e><Status code='404' text='Error loading
    > XML'></Status></Response></cXML>"
    > end if[/color]
    // above should be obvious.[color=blue]
    >
    > set objXML = nothing[/color]
    // tidy up memory.[color=blue]
    > %>
    >
    > ---------- [SCRIPT END] -----------[/color]

    Before I reply, I want to say I've never coded ASP in my life before,
    so I can't see why you wouldn't be able to figure it out, but
    nevertheless... .

    The code seems to be serializing the request object, then returning a
    little bit of XML to the browser, depending on the sucess of the
    request object save operation.

    Now, I'm not sure how you can do this in PHP quickly, but if you don't
    need the saved files to be XML, you could use serialize($_REQ UEST).
    Otherwise I think you will have to loop through the request elements
    and build the XML yourself, then save the file and return the relevant
    XML depending on it's sucess.

    Look at the code above, I've added some comments that might help you.

    Comment

    • Dino

      #3
      Re: HELP! transferring this short .asp-script to php....

      On Mon, 24 Apr 2006 16:06:00 +0200, Treefrog wrote
      (in message <1145887560.669 770.315870@i40g 2000cwc.googleg roups.com>):
      [color=blue]
      > Before I reply, I want to say I've never coded ASP in my life before,
      > so I can't see why you wouldn't be able to figure it out, but
      > nevertheless... .
      >
      > The code seems to be serializing the request object, then returning a
      > little bit of XML to the browser, depending on the sucess of the
      > request object save operation.
      >
      > Now, I'm not sure how you can do this in PHP quickly, but if you don't
      > need the saved files to be XML, you could use serialize($_REQ UEST).
      > Otherwise I think you will have to loop through the request elements
      > and build the XML yourself, then save the file and return the relevant
      > XML depending on it's sucess.[/color]


      hello treefrog,

      thanks for your help! the problem i had with the code was the way the data
      was transferred to the server. at fisrt, i tried to recieve the data with the
      $_POST and the $_GET array, but both were completely empty after the data was
      submitted by the shop system. this was very irritating because i did not
      understand how exactly the data was transferred (there was no doucmentation
      available, which made the whole thing ending up in try-and-error-sessions).
      AFAIK the $_REQUEST array combines $_GET, $_POST, $_COOKIE (and also $_FILES
      in PHP versions < 4.3.0). so i'm curious if the data can be found in the
      $_REQUEST array.

      thanks a lot again,

      best regards,
      dino

      Comment

      Working...