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

Does anyone know how to call a .NET web service from PERL? I created a very basic .NET web service locally on my machine. The web service accepts a parameter and perfoms a conversion on the input value. I need to use a PERL script to call this web service and then have the web service return back to the PERL script the result. I know so far that I have to use SOAP::Lite, but I am not sure how to use it? I have read the soaplite.com website for information, but somewhat confusing to me as I am new to PERL.

Any help would be greatly appreciated or a code snippet to try. This is what I have tried so far below, but the only thing that happens is I get the message on the last line printed out to my command window:
use SOAP::Lite; print SOAP::Lite -> uri('http://localhost/WebService1/Service1.asmx') -> proxy('http://localhost/WebService1/Service1.asmx') -> ConvertTemperature(0) -> result; print "test for soap call using SOAP::Lite";
The web service I have contains one exposed webmethod, ConvertTemperature, and it excepts a value and returns a result. Again, I am running this locally on my own machine. Thanks,

Replies are listed 'Best First'.
Re: How to call a .NET web service from PERL
by runrig (Abbot) on Jan 14, 2005 at 21:57 UTC
    IIRC, you have to jump through some hoops to get a perl SOAP::Lite client to talk to a .NET service (I don't have any direct experience, just a vague recollection from reading). It was covered in O'Reilly's (Programming Web Services with) SOAP book. Oh look, I think it's in chapter 3 of the book (under "Interoperability Issues"). I have no idea how up to date this info is, so YMMV.
Re: How to call a .NET web service from PERL
by bpphillips (Friar) on Jan 17, 2005 at 13:26 UTC
    In addition to some of the comments above, you might find this MSDN article helpful. It is titled "How to Call a .NET-based Web Service Using the SOAP::Lite Perl Library" and was helpful when I was recently doing the same thing you're trying to do.
Re: How to call a .NET web service from PERL
by hardburn (Abbot) on Jan 14, 2005 at 21:43 UTC

    The code here looks right. Are you sure the web service itself is working correctly?

    "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

      Here is my .NET Web service code:
      [WebMethod] public double ConvertTemperature(double dFahrenheit) { return ((dFahrenheit - 32) * 5) / 9; }
      I am using the standard example of Hello World from Visual Studio.NET and I added one more function. I can test this web service locally on my own machine by going directly to the URL (http://localhost/WebService1/Service1.asmx) and I get a web page to load asking me for input and providing a button to invoke.

      Is it my machine and the setup?
Re: How to call a .NET web service from PERL
by gellyfish (Monsignor) on Jan 17, 2005 at 11:38 UTC

    There are two things that you need to check in order to ensure interoperability with a .NET Web Service: firstly you need to provide the correct value for the uri method - this is used as the namespace for the XML payload of the SOAP request. If the namespace is not being explicitly being set in the [WebService] attribute in your c# code then this will have the value of http://tempuri.org/. Secondly you need to be sending the form of SOAPAction header that the .NET web service is expecting. You can generally achieve this by adding:

    ->on_action( sub { join "", @_ } )
    after the proxy() line.

    /J\