Search code examples
.netperlsoapwsdlservice-reference

Building Perl Soap Services that are Consumed by .NET


I have a Linux server with Perl libraries that I need to expose to a .NET application. Naturally I thought I would build out a platform independent solution, like SOAP, to bridge the gap. I'm finding this is not as easy as I was expecting.

As a mini proof of concept, I am trying to build out a hello world service in Perl. I've generated my code based off of this tutorial:

http://guide.soaplite.com/#quick%20start%20guide%20with%20soap%20and%20soap::lite

And peppered in some Pod::SOAP commenting that I found here: http://www.perlmonks.org/?node_id=632923

And ended up with this service:

#!/usr/bin/perl
use CGI;
use SOAP::Transport::HTTP;

SOAP::Transport::HTTP::CGI->dispatch_to('Demo')-> handle;

package Demo;

=begin WSDL
_RETURN $string
=end WSDL
=cut

sub hi {
    return "hello, world";
}

I generated a WSDL with this script:

#!#!/usr/bin/perl
use Pod::WSDL;

my $pod = new Pod::WSDL(source => '/var/www/html/perl/test.pl', location => 'http://localhost/perl/test.pl', pretty => 1, withDocumentation =>1);

print $pod->WSDL;

Low and behold, when I hit this script, I get a WSDL. I load it in to .NET 4.0 as a ServiceReference and think life is grand. But it's not.

When I try to envoke the reference like this:

var myWS = new ServiceReference1.DemoHandlerClient(new System.ServiceModel.BasicHttpBinding(), new System.ServiceModel.EndpointAddress(url));
string result = myWS.hi();

I end up getting this error out of the soap request:

SOAPAction shall match 'uri#method' if present (got 'http://localhost/Demo/DemoHandler/hiRequest', expected 'http://localhost/Demo#hi'

Clearly I see that .NET is not submitting the expected SOAPAction. What can I do to fix this? I suspect that if I were to use the perl SOAP::Lite library for the client that this would work fine.

Edit: Perhaps weirder yet--If I use Fiddler to capture the XML that .NET is sending over, and then manually send the same XML over using SoapUI I end up getting a valid response.


Solution

  • I used SOAP::Lite in 2006 to build a web service and it was such a bad experience that I've avoided ever since like the devil avoids holy water. If you are serious indeed on going the SOAP road, then I would very much suggest getting acquainted with XML::Compile suite of modules for XML Schema, SOAP and WSDL. I found the module much nicer to work with and there is a mailing list and the author is very responsive.

    Take a look at XML::Compile::SOAP::Daemon to learn how to build a server.