Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

GET AND POST Question

DJMattyDJMatty Posts: 1Member
Hi there,

I have to post an xml format(page body) and receive a seperate one returned by the page which will be generated by the parameters which i pass to the initial page.

Hope thats clear and not too vague..

Thanks

mdw...

Comments

  • WeirdofreakWeirdofreak Posts: 439Member
    Sorry, I don't understand what the problem is at all. However, to recieve parameters, use

    $cgi = new CGI;
    $param1 = $cgi -> param('nameofformelement1');
    $param2 = $cgi -> param('nofe2');

    Etc. I'm not sure if that'll be any use at all, though.
  • JonathanJonathan Posts: 2,914Member
    Hi,

    : I have to post an xml format(page body) and receive a seperate one
    : returned by the page which will be generated by the parameters which
    : i pass to the initial page.
    :
    Sounds like your doing something web-service-ish? I think you're looking for something a little like this:-

    [code]# Create a user agent object
    use LWP::UserAgent;
    $ua = LWP::UserAgent->new;

    # Create a request
    my $req = HTTP::Request->new(POST => 'http://somewhere.com/url/thing');
    $req->content_type('application/x-www-form-urlencoded');
    $req->content("someparam=x&xml=$your_escaped_xml");

    # Pass request to the user agent and get a response back
    my $res = $ua->request($req);

    # Check the outcome of the response
    if ($res->is_success) {
    print $res->content; # Or do proccessing of XML you get
    }
    else {
    print $res->status_line, "
    ";
    }[/code]

    Note you need to escape your XML for special characters, like the &'s. They are escpated to be %nn style values. For more info and an example that the above one was based on, see:-
    http://search.cpan.org/~gaas/libwww-perl-5.76/lib/LWP.pm#HTTP_STYLE_COMMUNICATION

    If you are doing web services, there is also an O'Reilly book named "Web Services With Perl" which may interest you.

    Hope this helps,

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.