Link to home
Start Free TrialLog in
Avatar of robids
robidsFlag for United States of America

asked on

soap::lite passing xml data to perl script.

Hi, I am writing a soap::lite client to send/receive xml request to a .net web service.
problem is the xml request is getting very complicated and deep. Its there a way to import a pre made xml file to the perl script and have the script create the body of the request from the xml file?
Thanks rob.
Avatar of Tobias
Tobias
Flag of Switzerland image

Hi !

I'm not sure what you want do.

Maybe with the module : XML::Parser

Best Regards
Avatar of robids

ASKER

Hi.  I need to send/receive xml request to a .net web service using soap:lite
below is the xml file that i need to send via soap::lite to the .net web sevice.
###
<Ver1.0>

<Header>
<LicenseId>2231</LicenseId>
<SiteId>201</SiteId>
<DeviceId>34401</DeviceId>
<UserName>11190017</UserName>
<Password>017</Password>
<SiteTrace>0001</SiteTrace>
</Header>

<Transaction>

<CreditAuth>

<Block1>

<CardData>

<TrackData method="swiped">
B4012002000060016 VI TEST CREDIT251210118039000000000396
                     
</TrackData>
</CardData>
<Amt>25</Amt>
<CPCReq>N</CPCReq>
<AllowDup>Y</AllowDup>

<AutoSubstantiation>

<FirstAdditionalAmtInfo>
<AmtType>4S</AmtType>
<Amt>60.00</Amt>
</FirstAdditionalAmtInfo>

<SecondAdditionalAmtInfo>
<AmtType>4V</AmtType>
<Amt>30.00</Amt>
</SecondAdditionalAmtInfo>
<AllowPartialAuth>Y</AllowPartialAuth>
<MerchantVerificationValue>123abc456d
                                </MerchantVerificationValue>
</AutoSubstantiation>
</Block1>
</CreditAuth>
</Transaction>
</Ver1.0>
###

how do i pass this xml file to the perl script???
thanks
> how do i pass this xml file to the perl script???
no, you perl script reads the file content and passes it as HTTP message body to the corresponding URL
Avatar of robids

ASKER

OK, Thats my question. How is this done?. I need to pass the data to the script so the data can be sent via the soap::lite mxl request to the .net webserver.
as long as you do not provide the code you have done so far it's difficult to give you proper samples. Probably following helps you:
   if (open(X,";
     SOAP::Data->name("yourdata" => $xml);
    # .. your other code
   }
Avatar of robids

ASKER

Thank you here is my code.
#!/usr/bin/perl
###my $WSDL="https://site.net/PosGatewayService.asmx?wsdl=wsdl1";
my $NS = "http://site.net/PosGatewayService/";
my $HOST = "https://site.net/PosGatewayService.asmx";
 
use strict;
use SOAP::Lite +trace => qw (debug);
 
my $search = SOAP::Lite
#->readable(1)
#->xmlschema('http://www.w3.org/2001/XMLSchema')
->on_action( sub { return '""';} )
->proxy($HOST)
->uri($NS);
 
my $method =  ### pull in xml file ###
my $results = $search->call($method  );
print $results;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robids

ASKER

wow that's it except the output request is turned into the following:

<Amt>25</Amt> &#xd;
instead of
<Amt>25</Amt>

can the be formatted?
Avatar of Adam314
Adam314

The above will read the your_xml_file.xml into $method.  No modification is done - the file is read exactly as it is.

I'm not sure what you want to do.... but to remove "&#xd;" you could use this:
    $var =~ s/&#xd;//;
Replace $var with whatever variable has the data.
Avatar of robids

ASKER

Thank You.
 The problem is with what the soap::lite does to the imported xml data. The soap envenlope gets changed to <Amt>25</Amt> &#xd; in stead of what is pass to the scrip 25 on the output.  I need to get the output formatted correctly. Thanks again for your help
hmm, what is the big difference between my suggestion and the graded one, may be I'm too blind for that ...
Yes, they are very similar.  I would be okay with a split.
Adam314, my wondering was meant for the questioner ;-)