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

OK, so I started at the deep end with my first SOAP::Lite service. I decided to start with one that that returns an XML document.

Heck, I even went to the bother of writing the WSDL file with the valid XSD in it, but there's one weeny glitch. I' m a bit thick, and can't quite figure SOAP::Data out to tell the outside world that, hey, this is an XML document that validates against this other schema over there, and it isn't a string.

Anyone got a piece of sample code that demonstrates returning something like: <foo><bar attrr="value" /></foo> (although mine is a touch more complex than that)

All help is much appreciated...

--
RatArsed

Replies are listed 'Best First'.
(jeffa) Re: SOAP::Lite and XML
by jeffa (Bishop) on Sep 05, 2002 at 13:40 UTC

    I am not sure that this fulfills your second paragraph, but it does the third. :)

    Server: (/usr/local/apache/cgi-bin/xml_soap.cgi)
    use strict; use SOAP::Transport::HTTP; use XML::Writer; use IO::String; SOAP::Transport::HTTP::CGI -> dispatch_to('Foo') -> handle ; package Foo; sub foo { my ($self,$value) = @_; my $output = IO::String->new; my $writer = XML::Writer->new( OUTPUT => $output, DATA_MODE => 1, DATA_INDENT => 3, ); $writer->startTag('foo'); $writer->emptyTag('bar',type => $value); $writer->endTag('foo'); $writer->end; return ${$output->string_ref}; }


    Client: (xml_soap_client.pl)
    use strict; use SOAP::Lite; print SOAP::Lite -> uri('http://localhost/Foo') -> proxy('http://localhost/cgi-bin/xml_soap.cgi') -> foo('baz') -> result ;

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Reading that code, I asusme it does something similar to what I have at the moment, serialising the XML as a string.

      I tried testing, but XML::Writer was not installed, and fails to install, nicely dumping the core, so I can't actually try the exact code at this point in time...

      --
      RatArsed