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

I have a SOAP server that dispatches to a module fine. Once it gets to the sendMsg2Vbs subroutine the incoming data is a hash that I cannot output to a file which is what I need to do. The incoming data is coming from a client that I have no control over. It's also loaded with tags containing attributes like this <Entity name="city" sectionEntityMapId="190" value="EAST DOVER"/>. Ultimately, I want to create an xml file with the entire incoming xml message. How do I do this? Thank you for your help.

Here is my SOAP server:

#!/usr/bin/perl use strict; use SOAP::Transport::HTTP; use lib '/var/www/soap'; use vbsservice; my $server = SOAP::Transport::HTTP::CGI ->dispatch_to('sendMsg2Vbs') ->handle; 1;

Here is the vbsservice module:

#!/usr/local/bin/perl package vbsservice; use Switch; use warnings; use Exporter; our @ISA = (Exporter); our @EXPORT = qw(sendMsg2Vbs); sub sendMsg2Vbs { my($class,$data)=@_; ...

I'd like to output $data to a file but it is a hash. Any help would be very much appreciated. Thank you.

Replies are listed 'Best First'.
Re: Caturing incoming XML from SOAP server
by NetWallah (Canon) on Jan 28, 2016 at 21:46 UTC
    It depends on the information in $data.

    If $data is a hashref with a single KEY, and if the VALUE of that key is an XML string, you can get to that string with something like:

    my ($xml) = values %$data; # You can now write the contents of $xml to a file...
    Give us more information on the contents of $data, if you need more help.

            "I can cast out either one of your demons, but not both of them." -- the XORcist

      Thank you for your help! I reposted my question because I realize that it's the ATTRIBUTES that are giving me trouble. Here's the thread. Thanks again for your help: http://www.perlmonks.org/?node_id=1155553

Re: Caturing incoming XML from SOAP server
by Anonymous Monk on Feb 19, 2016 at 01:49 UTC

      Thank you for your response! I tried your example and I received this error: Can't call method "context" on unblessed reference at /var/www/soap/vbsservice.pm line 55. I get this 'unblessed' error whenever I try accessing the data or som object. Any help would be appreciated. Thanks again.

        I tried your example and I received this error: Can't call method "context" on unblessed reference at /var/www/soap/vbsservice.pm line 55.

        Then you didn't try what I suggested, you probably left out the @ISA stuff