in reply to Why can't SOAP::Lite deserialize its own output?
SOAP is hard, good luck with that :)
Why can't SOAP::Lite deserialize its own output? Can someone please suggest how I might change the serializer or deserializer to resolve this issue.
I don't think you can blame SOAP::Lite here ... but I hate SOAP
If you do things the way SOAP::Lite wants you to, it seems to work
server output
$ perl soap-lite-server.pl Contact to SOAP server at http://127.0.0.1:10013/ OrderInquiry called $VAR1 = [ 'physi' ]; $VAR1 = { 'OrderInquiry' => { 'vorname' => 'physi' } }; $VAR1 = bless( { '_faultstring' => 'Died in server method', '_faultactor' => 'http://www.soaplite.com/custom', '_faultcode' => 'Server.Custom', '_faultdetail' => bless( { 'code' => 1 }, 'BadError' ) }, 'SOAP::Fault' ); Terminating on signal SIGINT(2) $
client output (you can see the $fault is parsed without die-ing)
POST http://localhost:10013/ HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/1.11 Content-Length: 456 Content-Type: text/xml; charset=utf-8 SOAPAction: "/Demo#OrderInquiry" <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <OrderInquiry xmlns="/Demo"> <vorname xsi:type="xsd:string">physi</vorname> </OrderInquiry> </soap:Body> </soap:Envelope> HTTP/1.1 200 OK Date: Thu, 03 Jul 2014 07:57:13 GMT Server: libwww-perl-daemon/6.01 Content-Length: 497 Content-Type: text/xml; charset=utf-8 Client-Date: Thu, 03 Jul 2014 07:57:13 GMT Client-Peer: 127.0.0.1:10013 Client-Response-Num: 1 SOAPServer: SOAP::Lite/Perl/1.11 <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <OrderInquiryResponse xmlns="/Demo"> <s-gensym3 xsi:type="xsd:string">OrderInquiry order Created</s-g +ensym3> </OrderInquiryResponse> </soap:Body> </soap:Envelope> POST http://localhost:10013/ HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap User-Agent: SOAP::Lite/Perl/1.11 Content-Length: 460 Content-Type: text/xml; charset=utf-8 SOAPAction: "/Demo#die_with_fault" <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <die_with_fault xmlns="/Demo"> <vorname xsi:type="xsd:string">physi</vorname> </die_with_fault> </soap:Body> </soap:Envelope> HTTP/1.1 500 Internal Server Error Date: Thu, 03 Jul 2014 07:57:13 GMT Server: libwww-perl-daemon/6.01 Content-Length: 687 Content-Type: text/xml; charset=utf-8 Client-Date: Thu, 03 Jul 2014 07:57:13 GMT Client-Peer: 127.0.0.1:10013 Client-Response-Num: 1 SOAPServer: SOAP::Lite/Perl/1.11 <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:namesp1="http://namespaces.soaplite.com/perl" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <soap:Fault> <faultcode>soap:Server.Custom</faultcode> <faultstring>Died in server method</faultstring> <faultactor>http://www.soaplite.com/custom</faultactor> <detail> <BadError xsi:type="namesp1:BadError"> <code xsi:type="xsd:int">1</code> </BadError> </detail> </soap:Fault> </soap:Body> </soap:Envelope> faultcode = soap:Server.Custom faultstring = Died in server method faultdetail = HASH(0x17beb14) faultactor = http://www.soaplite.com/custom
soap-lite-server.pl
#!/usr/bin/perl -- ## ## 2014-07-03-00:50:25 ## ## ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; Main( @ARGV ); exit( 0 ); sub Main { use SOAP::Transport::HTTP; my $daemon = SOAP::Transport::HTTP::Daemon->new( LocalAddr => 'localhost', LocalPort => 10013, Reuse => 1 )->dispatch_to( 'Demo' ); print "Contact to SOAP server at ", $daemon->url, "\n"; $daemon->handle; } ## end sub Main BEGIN { package Demo; use Data::Dumper; use vars qw(@ISA); @ISA = qw(SOAP::Server::Parameters); sub OrderInquiry { print "OrderInquiry called\n"; my $self = shift; my $envelope = pop; print Dumper( \@_ ); print Dumper( $envelope->valueof( '/Envelope/Body' ) ); return "OrderInquiry order Created"; } ## end sub OrderInquiry sub die_with_fault { my $fault = SOAP::Fault->faultcode( 'Server.Custom' ) # will be quali +fied ->faultstring( 'Died in server method' ) ->faultdetail( bless { code => 1 } => 'BadError' ) ->faultactor( 'http://www.soaplite.com/custom' ); print Dumper( $fault ); die $fault; } ## end sub die_with_fault 1; } ## end BEGIN __END__
soap-lite-client.pl
#!/usr/bin/perl -- ## ## 2014-07-03-00:50:25 ## ## ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use SOAP::Lite; Main( @ARGV ); exit( 0 ); sub Main { my $soap = SOAP::Lite->uri( '/Demo' )->proxy( 'http://localhost:10 +013/' ); $soap->transport->add_handler( "request_send", \&pp_dump ); $soap->transport->add_handler( "response_done", \&pp_dump ); $soap->OrderInquiry( SOAP::Data->name( vorname => 'physi' ) ); my $som = $soap->die_with_fault( SOAP::Data->name( vorname => 'phy +si' ) ); for my $method ( qw/ faultcode faultstring faultdetail faultactor + / ) { printf "%-20s = %s\n", $method, $som->$method; } } ## end sub Main sub pp_twig { use XML::Twig; open my( $fh ), '>', \my $str; no warnings 'newline'; #~ XML::Twig->new(qw! pretty_print record !)->xparse(@_)->print( $ +fh ); XML::Twig->new( qw! pretty_print record ! )->parse( @_ )->print( $ +fh ); $str =~ s/ xmlns:/\n xmlns:/g; return $str; } ## end sub pp_twig sub pp_dump { my $content = $_[0]->content( '' ); $_[0]->content( pp_twig( $content ) ); print $_[0]->as_string, "\n"; return; } ## end sub pp_dump
Good luck with that :)
Here is my copy/paste of my soap tips (I hate soap), SOAP::Lite is too much work, SOAP::Simple is less work (but its simple, when stuck go to XML::Compile::SOAP, more verbose, but you want verbose with SOAP ) ... its built on XML::Compile::SOAP/http://perl.overmeer.net/xml-compile/#doc , see my treasure trove of soap examples and lost knowledge,$soap->transport->add_handler("request_send", \&pp_dump );, http://cookbook.soaplite.com/, SOAP endpoint , Re^3: SOAP::Lite login setup, Re: I do not understand how to write a SOAP server., An XML Overview Towards Understanding SOAP, Re^3: SOAP::Lite and custom envelopes, The XML FIles: Understanding XML Namespaces, How to Call a .NET-based Web Service Using the SOAP::Lite Perl Library (2002 )
Good luck with that :)
|
|---|