in reply to Re: convert SOAP message to perl data structure
in thread convert SOAP message to perl data structure

Hi mav3067 :

Thanks for your help, this is what I get as "Response" :

<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body><consultaUnManifiestoResponse xmlns="http://Recintos/Servic +iosWebXml/"><consultaUnManifiestoResult> <error>0</error> <descripError /><registros>1</registros> <man><nTrans>465</nTrans> <cTransp>HYBU</cTransp> <idTransp>7116834 </idTransp> <nomBuque>ARGOSY</nomBuque> <numViaje>416 SB MEX</numViaje> <fecEstimada>15/12/2004 12:00:00 AM</fecEstimada> <tipoOper>1</tipoOper> <lineaNaviera>NAVIERA VICANE</lineaNaviera> <fecRecibe>14/12/2004 4:09:46 PM</fecRecibe> <cuAduana>53</cuAduana> <cuPais>ATG</cuPais> <cuPuerto>PMS</cuPuerto> <cuEntidadMan>1158</cuEntidadMan> <casos /></man><manifiestos><a nyType xsi:type="ObjManifiesto"> <nTrans>465</nTrans> <cTransp>HYBU</cTransp> <idTransp>7116834 </idTransp> <nomBuque>ARGOSY</nomBuque> <numViaje>416 SB MEX</numViaje> <fecEstimada>15/12/2004 12:00:00 AM</fecEstimada> <tipoOper>1</tipoOper> <lineaNaviera>NAVIERA VICANE</lineaNaviera> <fecRecibe>14/12/2004 4:09:46 PM</fecRecibe> <cuAduana>53</cuAduana> <cuPais>ATG</cuPais><cuPuerto>PMS</cuPuerto> <cuEntidadMan>1158</cuEntidadMan> <casos /></anyType></manifiestos> </consultaUnManifiestoR esult></consultaUnManifiestoResponse></soap:Body></soap:Envelope>

How can I convert to Perl data structure or insert into a Mysql table ??

Again, thanks for your help,

Caribesoft.

20060712 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re^3: convert SOAP message to perl data structure
by gellyfish (Monsignor) on Jul 12, 2006 at 08:32 UTC

    Is that really what you are getting back? This doesn't appear to "well formed XML" as there is a closing </anyType> without a corresponding opening one. If it really is what you are getting back then you will need to fix that problem before attempting to process it.

    /J\

      HI : Thanks for your comments, I have read a lot of SOAP and XML but I cannont undertand yet how can I get the data and transfer to Perl data stucture. If you see the label <anytype xsi:type="objManifiesto"> exist after <manifiestos> ... In my script I have the above line, is this the one that display the dat ? code if($response->code == 200) { print $response->as_string; } How can I get each field from $response-> ? Best regards, Caribesoft /code

        If you are using LWP::UserAgent as it appears then you might just as well do something like:

        # .. your modules use XML::Simple; use Data::Dumper; # make request and get response; # ... my $data = XMLin($response->as_string); # the following just to show you the structure. print Dumper($data);
        You should read the XML::Simple documentation for more on how to control the parsed data structure.

        /J\