soap::lite  passing xml data to perl script.

Posted on 2008-10-20
Last Modified: 2013-11-05
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.
Question by:robids
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +1
LVL 10

Expert Comment

ID: 22767028
Hi !

I'm not sure what you want do.

Maybe with the module : XML::Parser

Best Regards

Author Comment

ID: 22767061
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.






<TrackData method="swiped">
B4012002000060016 VI TEST CREDIT251210118039000000000396




how do i pass this xml file to the perl script???
LVL 51

Expert Comment

ID: 22767268
> 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.


Author Comment

ID: 22769168
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.
LVL 51

Expert Comment

ID: 22769807
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

Author Comment

ID: 22770027
Thank you here is my code.
###my $WSDL="";
my $NS = "";
my $HOST = "";
use strict;
use SOAP::Lite +trace => qw (debug);
my $search = SOAP::Lite
->on_action( sub { return '""';} )
my $method =  ### pull in xml file ###
my $results = $search->call($method  );
print $results;

Open in new window

LVL 39

Accepted Solution

Adam314 earned 125 total points
ID: 22771863
Use this for your line 16
my $method;
open(my $in, "<your_xml_file.xml") or die "Could not open xml: $!\n";
{local $/;

Open in new window


Author Comment

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

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

can the be formatted?
LVL 39

Expert Comment

ID: 22772531
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.

Author Closing Comment

ID: 31508108
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
LVL 51

Expert Comment

ID: 22790745
hmm, what is the big difference between my suggestion and the graded one, may be I'm too blind for that ...
LVL 39

Expert Comment

ID: 22791305
Yes, they are very similar.  I would be okay with a split.
LVL 51

Expert Comment

ID: 22803893
Adam314, my wondering was meant for the questioner ;-)

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question