http://qs321.pair.com?node_id=391819


in reply to WSDL generation for a SOAP::Lite server

I actually have been in the middle of this same thing for several weeks now and have some suggestions.

WSDL::Generator is kind of neat - but it is also a pain. I skipped the tests and installed the module itself (there is no binary portion). I hooked it just fine and it spat out a WSDL that would probably work just fine - actually it would work just fine. But it was ugly.

The solution I finally came down to was to hand code my own. I read about the WSDL spec. I also had recently been working the Net::Google which happens to have a WSDL document embedded in it. The Google WSDL is a good example of complex return types and various request data types. With this information in hand I coded my own WSDL.

The next step is making sure that using SOAP::Lite, as the server, would return the appropriately formatted XML. To debug what was getting input and output for the XML, I added the following code segments to SOAP/Lite.pm.
# inserted at line 2281 before the "my $result =" line my $file = "/tmp/soap.in.xml"; if (open (my $fh,">$file")) { print $fh $_[0]; warn $file; } else { die "Couldn't open: $file"; }

And
# inserted at line 2348 before the "return $t" line my $file = "/tmp/soap.out.xml"; if (open (my $fh,">$file")) { print $fh $t; warn $file; } else { die "Couldn't open: $file"; }

With the XML in hand, I could now make sure that my return data was getting serialized correctly. I made a special class that I blessed the data into. I then had a custom serializer that would look for that data type and when it was found, would invoke a custom package that inherited SOAP::Data to encapsulate the data correctly and did any touch ups on the XML attributes.

Phew...

I found myself thinking that we really need a new WSDL generator (anybody with time is welcome). All it needs to do is take a data structure for the request, and a data structure for the response, and have a few extra fields for specifics, and spit out the WSDL. WSDL::Generator currently tries to use too much magic, and the resulting WSDL is not exactly easy to document. Maybe if I get some free cycles or some round toits I'll try and create the module.

Hope this has helped.

my @a=qw(random brilliant braindead); print $a[rand(@a)];