Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

XML module advice

by fuzzyping (Chaplain)
on Jun 07, 2004 at 03:33 UTC ( [id://361858]=perlquestion: print w/replies, xml ) Need Help??

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

I'm looking to integrate EFSnet's payment gateway interface into a client application. I haven't done much work with XML (although I understand the basics), so I'm looking for suggested XML modules to get this work done.

A sample HTTPS POST would go like this:
<Request StoreID="myStoreID" StoreKey="myStoreKey" ApplicationID="EFSn +et samples 1.0"> <CreditCardAuthorize> <ReferenceNumber>1234</ReferenceNumber> <TransactionAmount>1.00</TransactionAmount> <AccountNumber>4111111111111111</AccountNumber> <ExpirationMonth>12</ExpirationMonth> <ExpirationYear>99</ExpirationYear> </CreditCardAuthorize> </Request>
And the reply:
<Reply> <TransactionReply> <ResponseCode>0</ResponseCode> <ResultCode>00</ResultCode> <ResultMessage>APPROVED</ResultMessage> <TransactionID>100000182165</TransactionID> <AVSResponseCode /> <CVVResponseCode /> <ApprovalNumber>123456</ApprovalNumber> <AuthorizationNumber>123456</AuthorizationNumber> <TransactionDate>021112</TransactionDate> <TransactionTime>110544</TransactionTime> <ReferenceNumber>1234</ReferenceNumber> <AccountNumber>XXXXXXXXXXXX1111</AccountNumber> <TransactionAmount>1.00</TransactionAmount> </TransactionReply> </Reply>
Any suggestions on what I might use to a) markup and send the HTTPS POST (XML) connection, and b) accept/parse the reply?

Thanks in advance,

-fp

Replies are listed 'Best First'.
Re: XML module advice
by Enlil (Parson) on Jun 07, 2004 at 06:49 UTC
    I haven't done much work with XML (although I understand the basics), so I'm looking for suggested XML modules to get this work done.

    A good place to look for a comparison of the various XML documents you might want to look at the Perl-XML FAQ

    Any suggestions on what I might use to a) markup and send the HTTPS POST (XML) connection

    Here is one way to do it. (well the posting part anyhow);

    and b) accept/parse the reply?

    Personally, I tend to veer toward XML::Simple for most of my XML needs.

    Good Luck

    -enlil

Re: XML module advice
by tachyon (Chancellor) on Jun 07, 2004 at 08:23 UTC

    Essentially this is a trivial use of XML. The data could just as easily have been sent as Field: Value. You could quite easily just interpolate values into a post string to get the required format for the post data and then use LWP::UserAgent to do the POST and accept the REPLY. To parse the sort of trivial reply you have to deal with you could use XML::Simple. If you are certain that the XML will always be well formed you could use a simple RE (but this is not recommended)....

    while(<DATA>){ next unless m!^\s*<([^>]+)>([^<]+)</(\1)>!; $h{$1}=$2; } use Data::Dumper; print Dumper \%h; __DATA__ <Reply> <TransactionReply> <ResponseCode>0</ResponseCode> <ResultCode>00</ResultCode> <ResultMessage>APPROVED</ResultMessage> <TransactionID>100000182165</TransactionID> <AVSResponseCode /> <CVVResponseCode /> <ApprovalNumber>123456</ApprovalNumber> <AuthorizationNumber>123456</AuthorizationNumber> <TransactionDate>021112</TransactionDate> <TransactionTime>110544</TransactionTime> <ReferenceNumber>1234</ReferenceNumber> <AccountNumber>XXXXXXXXXXXX1111</AccountNumber> <TransactionAmount>1.00</TransactionAmount> </TransactionReply> </Reply>

    cheers

    tachyon

      Don't forget to decode any XML escaped charaters in the value ($2).
Re: XML module advice
by inman (Curate) on Jun 07, 2004 at 12:51 UTC
    XML::DOM is an in depth treatment of a Perl interface for XML. This is a heavier interface that XML::Simple but allows you to do use features such as validating the XML document against a DTD.

    XML::Writer is worth a look for writing XML.

      For something a bit more in depth, I would actually recommend XML::LibXML over XML::DOM. XML::LibXML is actively maintained and is lightning fast. XML::DOM got somewhat neglected by Enno until TJ Mather rescued it last year and put out a release.

      Personally I use XML::LibXML both for it's speed (based on libxml2 instead of expat) and because it validates XML against DTDs nicely.

      Oh, did I mention how fast XML::LibXML is?

      -- vek --
Re: XML module advice
by SciDude (Friar) on Jun 07, 2004 at 21:12 UTC

    The EFSNet site suggests a solution to your problem. Did you experiment with the SOAP::Lite code samples provided by them:

    # Note: To use this sample, insert your issued StoreID and StoreKey va +lues where appropriate. # This sample Perl code demonstrates calling the EFSnet SystemCheck me +thod via the SOAP interface. # This code requires SOAP::Lite and its pre-requisites (http://www.soa +plite.com/). use SOAP::Lite; # Call EFSnet SystemCheck method @OutputParams = SOAP::Lite -> service('https://testefsnet.concordebiz.com/EFSnet2.wsdl') -> SystemCheck('myStoreID', 'myStoreKey', 'EFSnet samples 1.0'); # Get output variables $ResponseCode = $OutputParams[0]; $ResultCode = $OutputParams[1]; $ResultMessage = $OutputParams[2];

    SciDude
    The first dog barks... all other dogs bark at the first dog.
      Yes, I did. The SOAP SystemCheck method they provide for testing works fine, but neither their XML or CGI interfaces are authenticating successfully for me. The SOAP interface appears easy to use, but none of the other methods work at all for me. I'll be calling their support line soon.

      -fp
Re: XML module advice
by gmpassos (Priest) on Jun 08, 2004 at 01:33 UTC
    XML::Smart:
    use XML::Smart ; my $url = 'http://www.perlmonks.org/index.pl?node_id=16046' ; my $XML = XML::Smart->new($url) ; my $sitename = $XML->{XPINFO}{INFO}{sitename} ; my $user = $XML->{XPINFO}{INFO}{foruser} ; my $id = $XML->{XPINFO}{INFO}{id} ; my $msg = $XML->{XPINFO}{INFO} ; ## Generating the XML data again: print $XML->data ;

    Graciliano M. P.
    "Creativity is the expression of the liberty".

Re: XML module advice
by Anonymous Monk on Jun 07, 2004 at 13:23 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://361858]
Front-paged by TStanley
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-24 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found