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.
robidsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TobiasCommented:
Hi !

I'm not sure what you want do.

Maybe with the module : XML::Parser

Best Regards
0
robidsAuthor Commented:
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
0
ahoffmannCommented:
> 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
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

robidsAuthor Commented:
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.
0
ahoffmannCommented:
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
   }
0
robidsAuthor Commented:
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

0
Adam314Commented:
Use this for your line 16
my $method;
open(my $in, "<your_xml_file.xml") or die "Could not open xml: $!\n";
{local $/;
$method=<$in>;
}
close($in);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
robidsAuthor Commented:
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?
0
Adam314Commented:
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.
0
robidsAuthor Commented:
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
0
ahoffmannCommented:
hmm, what is the big difference between my suggestion and the graded one, may be I'm too blind for that ...
0
Adam314Commented:
Yes, they are very similar.  I would be okay with a split.
0
ahoffmannCommented:
Adam314, my wondering was meant for the questioner ;-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.