robids
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.
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.
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</UserNa me>
<Password>017</Password>
<SiteTrace>0001</SiteTrace >
</Header>
<Transaction>
<CreditAuth>
<Block1>
<CardData>
<TrackData method="swiped">
B4012002000060016 VI TEST CREDIT25121011803900000000 0396
</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</Allow PartialAut h>
<MerchantVerificationValue >123abc456 d
</MerchantVerificationValu e>
</AutoSubstantiation>
</Block1>
</CreditAuth>
</Transaction>
</Ver1.0>
###
how do i pass this xml file to the perl script???
thanks
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</UserNa
<Password>017</Password>
<SiteTrace>0001</SiteTrace
</Header>
<Transaction>
<CreditAuth>
<Block1>
<CardData>
<TrackData method="swiped">
B4012002000060016 VI TEST CREDIT25121011803900000000
</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</Allow
<MerchantVerificationValue
</MerchantVerificationValu
</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
no, you perl script reads the file content and passes it as HTTP message body to the corresponding URL
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
}
if (open(X,";
SOAP::Data->name("yourdata
# .. your other code
}
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;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wow that's it except the output request is turned into the following:
<Amt>25</Amt> 
instead of
<Amt>25</Amt>
can the be formatted?
<Amt>25</Amt> 
instead of
<Amt>25</Amt>
can the be formatted?
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 "
" you could use this:
$var =~ s/
//;
Replace $var with whatever variable has the data.
I'm not sure what you want to do.... but to remove "
" you could use this:
$var =~ s/
//;
Replace $var with whatever variable has the data.
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> 
 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
The problem is with what the soap::lite does to the imported xml data. The soap envenlope gets changed to <Amt>25</Amt> 
 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 ;-)
I'm not sure what you want do.
Maybe with the module : XML::Parser
Best Regards