Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Why SOAP::Lite Method call returned partially XML formatted?

by Anonymous Monk
on Sep 14, 2008 at 04:40 UTC ( #711228=note: print w/ replies, xml ) Need Help??


in reply to Why SOAP::Lite Method call returned partially XML formatted?

I don't believe it does. Please write a runnable code sample that demonstrates this problem.


Comment on Re: Why SOAP::Lite Method call returned partially XML formatted?
Re^2: Why SOAP::Lite Method call returned partially XML formatted?
by Anonymous Monk on Sep 14, 2008 at 04:45 UTC
    Here's my example, SOAP::Lite v0.710.5, I used fujiman's response
    #!/usr/bin/perl -- use strict; use warnings; my $response = <<'__RESPONSE__'; SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Sun, 14 Sep 2008 03:11:44 GMT Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=utf-8 Client-Date: Sun, 14 Sep 2008 03:11:39 GMT Client-Peer: 65.120.87.83:8180 Client-Response-Num: 1 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <doSelectResponse xmlns="test"> <doSelectReturn xmlns="">&lt;?xml version=&quot;1.0&quot; encoding= +&quot;UTF-8&quot;?&gt;&#xd; &lt;UDSObjectList&gt;&#xd; &lt;UDSObject&gt;&#xd; &lt;Handle&gt;pcat:400004&lt;/Handle&gt;&#xd; &lt;Attributes&gt;&#xd; &lt;Attribute DataType=&quot;2002&quot;&gt;&#xd; &lt;AttrName&gt;sym&lt;/AttrName&gt;&#xd; &lt;AttrValue&gt;Hosted Solutions Support&lt;/AttrValue&gt;&#xd; &lt;/Attribute&gt;&#xd; &lt;Attribute DataType=&quot;2002&quot;&gt;&#xd; &lt;AttrName&gt;description&lt;/AttrName&gt;&#xd; &lt;AttrValue/&gt;&#xd; &lt;/Attribute&gt;&#xd; &lt;/Attributes&gt;&#xd; &lt;/UDSObject&gt;&#xd; &lt;/UDSObjectList&gt;&#xd; &#xd; </doSelectReturn> </doSelectResponse> </soapenv:Body> </soapenv:Envelope> __RESPONSE__ my $response_xml = $1 if $response=~ /.+?(<\?xml.+Envelope>)\s*$/s; use XML::Simple; use Data::Dumper; $Data::Dumper::Indent=1; print Dumper( XMLin( $response_xml )), $/,'----',$/; use SOAP::Lite; my $d = SOAP::Custom::XML::Deserializer->deserialize( $response_xml ); print $d->valueof('/Envelope/Body'), $/,'----',$/; __END__ $VAR1 = { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'soapenv:Body' => { 'doSelectResponse' => { 'xmlns' => 'test', 'doSelectReturn' => { 'xmlns' => '', 'content' => '<?xml version="1.0" encoding="UTF-8"?> <UDSObjectList> <UDSObject> <Handle>pcat:400004</Handle> <Attributes> <Attribute DataType="2002"> <AttrName>sym</AttrName> <AttrValue>Hosted Solutions Support</AttrValue> </Attribute> <Attribute DataType="2002"> <AttrName>description</AttrName> <AttrValue/> </Attribute> </Attributes> </UDSObject> </UDSObjectList> ' } } }, 'xmlns:soapenv' => 'http://schemas.xmlsoap.org/soap/envelope/' }; ---- <?xml version="1.0" encoding="UTF-8"?> <UDSObjectList> <UDSObject> <Handle>pcat:400004</Handle> <Attributes> <Attribute DataType="2002"> <AttrName>sym</AttrName> <AttrValue>Hosted Solutions Support</AttrValue> </Attribute> <Attribute DataType="2002"> <AttrName>description</AttrName> <AttrValue/> </Attribute> </Attributes> </UDSObject> </UDSObjectList> ----
Re^2: Why SOAP::Lite Method call returned partially XML formatted?
by fujiman (Novice) on Sep 15, 2008 at 19:09 UTC
    Hi there,

    Here is a full sample of my code that calls the doSelect web service function. In the code sample I make a retrieveCategories subroutine call that prints the full result and valueof result. Notice, the full result is correctly displayed but valueof method does not return the value.

    Here is my code sample

    #!/usr/bin/perl -w use SOAP::Lite trace=>'debug'; #use SOAP::Lite; use Data::Dumper; use strict; # Perl sub routine to call Service Desk login method # and specify Service Desk Web Services end point sub login_get_SID { # Edit $server, $user and $pw as needed. my $server = '192.168.1.152:8180'; my $endpoint = '/axis/services/USD_R11_WebService?WSDL'; my $user = ''; #user id my $pw = ''; #user pwd my $wsdl = 'http://' . $server . $endpoint; my $service = SOAP::Lite->service($wsdl); my $sid = $service->login($user, $pw); return ($service, $sid); } # Always a best practice to call logout() when done sub logout { my ($service, $sid) = @_; $service->logout($sid) } # method to retrieve all Incident Areas sub retrieveCategories { my ($service, $sid, $service_name) = @_; my $method = SOAP::Data->uri('http://www.ca.com/UnicenterServicePl +us/ServiceDesk')->name('doSelect'); # Attributes for object to be created can be pulled # from majic files. my @params = ( SOAP::Data->name("sid" => $sid), SOAP::Data->name("objectType" => 'pcat'), SOAP::Data->name("whereClause" => "sym like 'Appl% +'"), SOAP::Data->name("maxRows" => "1"), SOAP::Data->name("attributes" => \SOAP::Data->value( SOAP::Data->name("string" => "sym"), SOAP::Data->name("string" => 'description') ) ), ); #print "dumper: ".Dumper(@params)."\n"; my $result = $service->call($method => @params); print "----result method call ---\n".$result->result."----- end re +sult ----\n"; print "----valueof method call ----\n".$result->valueof('//AttrNam +e[1]')."----- end valueof ----\n"; return ($result); } # Main calls my ($service, $sid) = login_get_SID(); retrieveCategories($service, $sid); logout($service, $sid);

    Here is the output from retrieveCategories() subroutine:

    ----result method call --- <?xml version="1.0" encoding="UTF-8"?> <UDSObjectList> <UDSObject> <Handle>pcat:5103</Handle> <Attributes> <Attribute DataType="2002"> <AttrName>sym</AttrName> <AttrValue>Applications</AttrValue> </Attribute> <Attribute DataType="2002"> <AttrName>description</AttrName> <AttrValue>Applications</AttrValue> </Attribute> </Attributes> </UDSObject> </UDSObjectList> ----- end result ---- ----valueof method call ---- ----- end valueof ----

    This section is the full trace output.

    SOAP::Transport::HTTP::Client::send_receive: POST http://192.168.1.152 +:8180/axis/services/USD_R11_WebService HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 713 Content-Type: text/xml; charset=utf-8 SOAPAction: "" <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h +ttp://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.ap +ache.org/xml-soap" soap:encodingStyle="http://schemas.xmlsoap.org/soa +p/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" x +mlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://www.c +a.com/UnicenterServicePlus/ServiceDesk" xmlns:xsi="http://www.w3.org/ +2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/so +ap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body +><impl:login><username xsi:type="xsd:string">ServiceDesk</username><p +assword xsi:type="xsd:string">Un1c3nt3r</password></impl:login></soap +:Body></soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Mon, 15 Sep 2008 18:58:44 GMT Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=utf-8 Client-Date: Mon, 15 Sep 2008 18:58:45 GMT Client-Peer: 192.168.1.152:8180 Client-Response-Num: 1 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <loginResponse xmlns="http://www.ca.com/UnicenterServicePlus/Service +Desk"> <loginReturn xsi:type="xsd:int" xmlns="">639087957</loginReturn> </loginResponse> </soapenv:Body> </soapenv:Envelope> SOAP::Transport::HTTP::Client::send_receive: POST http://192.168.1.152 +:8180/axis/services/USD_R11_WebService HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/0.710.05 Content-Length: 1000 Content-Type: text/xml; charset=utf-8 SOAPAction: "" <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h +ttp://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.ap +ache.org/xml-soap" xmlns:namesp7="http://www.ca.com/UnicenterServiceP +lus/ServiceDesk" soap:encodingStyle="http://schemas.xmlsoap.org/soap/ +encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xml +ns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.o +rg/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org +/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:B +ody><namesp7:doSelect xmlns:namesp7="http://www.ca.com/UnicenterServi +cePlus/ServiceDesk"><sid xsi:type="xsd:int">639087957</sid><objectTyp +e xsi:type="xsd:string">pcat</objectType><whereClause xsi:type="xsd:s +tring">sym like 'Appl%'</whereClause><maxRows xsi:type="xsd:int">1</m +axRows><attributes><string xsi:type="xsd:string">sym</string><string +xsi:type="xsd:string">description</string></attributes></namesp7:doSe +lect></soap:Body></soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Mon, 15 Sep 2008 18:58:44 GMT Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=utf-8 Client-Date: Mon, 15 Sep 2008 18:58:46 GMT Client-Peer: 192.168.1.152:8180 Client-Response-Num: 1 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <doSelectResponse xmlns="http://www.ca.com/UnicenterServicePlus/Serv +iceDesk"> <doSelectReturn xmlns="">&lt;?xml version=&quot;1.0&quot; encoding= +&quot;UTF-8&quot;?&gt;&#xd; &lt;UDSObjectList&gt;&#xd; &lt;UDSObject&gt;&#xd; &lt;Handle&gt;pcat:5103&lt;/Handle&gt;&#xd; &lt;Attributes&gt;&#xd; &lt;Attribute DataType=&quot;2002&quot;&gt;&#xd; &lt;AttrName&gt;sym&lt;/AttrName&gt;&#xd; &lt;AttrValue&gt;Applications&lt;/AttrValue&gt;&#xd; &lt;/Attribute&gt;&#xd; &lt;Attribute DataType=&quot;2002&quot;&gt;&#xd; &lt;AttrName&gt;description&lt;/AttrName&gt;&#xd; &lt;AttrValue&gt;Applications&lt;/AttrValue&gt;&#xd; &lt;/Attribute&gt;&#xd; &lt;/Attributes&gt;&#xd; &lt;/UDSObject&gt;&#xd; &lt;/UDSObjectList&gt;&#xd; &#xd; </doSelectReturn> </doSelectResponse> </soapenv:Body> </soapenv:Envelope> Use of uninitialized value in concatenation (.) or string at C:\dev\us +dservices\perlmonk_sample.pl line 54. SOAP::Transport::HTTP::Client::send_receive: POST http://192.168.1.152 +:8180/axis/services/USD_R11_WebService HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/0.710.05 Content-Length: 648 Content-Type: text/xml; charset=utf-8 SOAPAction: "" <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:wsdlsoap="h +ttp://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.ap +ache.org/xml-soap" soap:encodingStyle="http://schemas.xmlsoap.org/soa +p/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" x +mlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:impl="http://www.c +a.com/UnicenterServicePlus/ServiceDesk" xmlns:xsi="http://www.w3.org/ +2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/so +ap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body +><impl:logout><sid xsi:type="xsd:int">639087957</sid></impl:logout></ +soap:Body></soap:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Connection: close Date: Mon, 15 Sep 2008 18:58:46 GMT Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=utf-8 Client-Date: Mon, 15 Sep 2008 18:58:47 GMT Client-Peer: 192.168.1.152:8180 Client-Response-Num: 1 <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:// +www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <logoutResponse xmlns="http://www.ca.com/UnicenterServicePlus/Servic +eDesk"/> </soapenv:Body> </soapenv:Envelope>

    Thanks,

    fujiman
      See Re^2: Why SOAP::Lite Method call returned partially XML formatted?

      That is exactly what you would expect to happen. It has nothing to do with SOAP::Lite serialization. Basically USD_R11_WebService (or whatever its called) double encoded some xml (stuffed an entire xml document into <doSelectReturn xmlns=""></doSelectReturn> ). The response (an xml document) doesn't contain any AttrNam elements.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-07-10 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (202 votes), past polls