Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^5: Accessing Attributes in Web Servie message - Server Side

by poj (Abbot)
on Feb 18, 2016 at 19:38 UTC ( [id://1155579]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Accessing Attributes in Web Servie message - Server Side
in thread Accessing Attributes in Web Servie message - Server Side

If you want to parse the XML then XML::Twig is one option

#!perl use strict; use warnings; use XML::Twig; use Data::Dumper; my $xml = do{local $/;<DATA>}; my %data=(); my $t = XML::Twig->new( twig_handlers=> { Section => \&section }, ); $t->parse($xml); print Dumper \%data; sub section { my ($t,$e) = @_; my $type = $e->att('type'); for ($e->children('Entity')){ push @{$data{$type}},$_->atts; } }; __DATA__
<sendMsg2ABC> <Request_Update_Message> <Action>APPROVE</Action> <Request_Id>999999</Request_Id> <NegotiatorName>MICHELLE</NegotiatorName> <NegotiatorPhone>800-555-5555</NegotiatorPhone> <VtacContactName>CYNTHIA</VtacContactName> <VtacContactPhone>555-555-5555</VtacContactPhone> <RequestType>CHANGE</RequestType> <RequestStatus>PENDING</RequestStatus> <IssuedDate>12/10/2015 09:29:02 AM</IssuedDate> <Section type="A"> <Entity name="requestdate" sectionEntityMapId="176" value="12/14 +/2015"/> <Entity name="servicetype" sectionEntityMapId="177" value="LOCAL +"/> <Entity name="npanxx" sectionEntityMapId="178" value="732270"/> <Entity name="host" sectionEntityMapId="179" value="NJ01D5"/> <Entity name="clli" sectionEntityMapId="182" value="NJ01D5"/> <Entity name="area" sectionEntityMapId="183" value="NJ"/> <Entity name="nodetype" sectionEntityMapId="184" value="100"/> <Entity name="serviceorders" sectionEntityMapId="185" value="R62 +2"/> <Entity name="englishname" sectionEntityMapId="186" value="EAST +NOWHERE"/> <Entity name="ratecenter" sectionEntityMapId="8045" value="TOMS +HOUSE"/> </Section> <Section type="B"> <Entity name="customername" sectionEntityMapId="188" value="USA" +/> <Entity name="address" sectionEntityMapId="189" value="857 Big R +oad"/> <Entity name="city" sectionEntityMapId="190" value="EAST NOWHERE +"/> <Entity name="state" sectionEntityMapId="191" value="NJ"/> <Entity name="customercontact" sectionEntityMapId="192" value="M +ORGAN"/> <Entity name="contactnumber" sectionEntityMapId="193" value="555 +-555-5555"/> <Entity name="mainphone" sectionEntityMapId="194" value="555-555 +-5555"/> <Entity name="TLI" sectionEntityMapId="195" value="555-555-7000" +/> <Entity name="remstationrange" sectionEntityMapId="201" value="5 +55-555-7000"/> <Entity name="numoflinesrem" sectionEntityMapId="202" value="1"/ +> <Entity name="port" sectionEntityMapId="203" value="N"/> <Entity name="pset" sectionEntityMapId="206" value="N"/> <Entity name="special" sectionEntityMapId="207" value="N"/> <Entity name="tg" sectionEntityMapId="209" value="0615"/> <Entity name="rti" sectionEntityMapId="210" value="NA"/> <Entity name="remarks" sectionEntityMapId="212" value="NO WORK; +SAME DATE FOR PORT; THANKS"/> </Section> <Section type="N"> <Entity name="swc" sectionEntityMapId="217" value="732555"/> <Entity name="wirecenter" sectionEntityMapId="218" value="EAST N +OWHERE"/> <Entity name="serviceorders" sectionEntityMapId="219" value="R66 +22"/> <Entity name="vremarks" sectionEntityMapId="222" value="No Work +Required]"/> </Section> </Request_Update_Message> </sendMsg2ABC>
poj

Replies are listed 'Best First'.
Re^6: Accessing Attributes in Web Servie message - Server Side
by gackles (Novice) on Feb 18, 2016 at 20:40 UTC

    Thank you poj. Trying to determine where to apply your example. Would I make that the main web service? or you that be the module that my soap server dispatches to?

      What do you get if you dump $envelope

      use Data::Dumper; sub sendMsg2ABC { my ($class,$data)=@_; my $envelope = pop @_; print Dumper $envelope;
      poj
Re^6: Accessing Attributes in Web Servie message - Server Side
by Anonymous Monk on Feb 19, 2016 at 00:29 UTC

    If you want to parse the XML then XML::Twig is one option

    kinda goes against the idea of a SOAP server to have to parse XML yourself :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1155579]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 22:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found