CounterSoft Community Server

Welcome to CounterSoft Community Server Sign in | Join | Help
Home Forums

HOWTO: Call web service from perl script

Last post 03-09-2006, 6:56 PM by denap. 4 replies.
Sort Posts:
  •  02-28-2006, 8:40 PM

    HOWTO: Call web service from perl script

    Below is a perl script kindly provided by one of our customers who wishes to remain annonymous:

    " thought the following may be useful; An example Perl script to access the Gemini Web Services - you may want to make it more widely available, as I've not seen one elsewhere. "

    -- Begin Perl --
    #!/usr/local/bin/perl -w

    #
    # Local settings
    #
    use constant GEMINI_URL => 'http://localhost/Gemini';               # Note - no trailing '/'
    use constant GEMINI_ACCESS_CODE => 'SomethingOtherThanABC123';      # As specified in Web.config
    use constant DEBUG => 0;
    $ENV{HTTP_proxy} = '';

    #
    # Common settings
    #
    use constant GEMINI_WS_URI => 'http://countersoft.com/gemini/webservices/';

    use strict;
    use warnings;
    use SOAP::Lite maptype => {};

    #
    # Turn on tracing, if we're in debug mode
    #
    SOAP::Lite->import(+trace => "all") if DEBUG;

    #
    # Create a SOAP handler
    #
    print "Generating SOAP handler\n" if DEBUG;
    my $soapHandler = SOAP::Lite
                        -> uri( GEMINI_WS_URI )
                        -> on_action( sub { join '', GEMINI_WS_URI, $_[1] } )
                        -> proxy( GEMINI_URL.'/webservices/Gemini.asmx' );

    #
    # Generate a "GetIssue" request
    #
    my $issueID = 1;
    print "Generating request for issue $issueID\n" if DEBUG;
    my $getIssue = SOAP::Data->name('GetIssue')
                        ->attr({xmlns => GEMINI_WS_URI});

     

    #
    # Set the parameters to "GetIssue"
    #
    print "Generating params for request\n" if DEBUG;
    my @params = ( SOAP::Data->name( accessCode => GEMINI_ACCESS_CODE ),
                    SOAP::Data->name( issueID => $issueID ) );

    #
    # Send the request
    #
    print "Sending request\n" if DEBUG;
    my $soapResponse = $soapHandler->call($getIssue => @params);

    #
    # Extract the response we want
    #
    my $issueSummary = $soapResponse->valueof('//GetIssueResult/IssueSummary' );
    print "Summary of issue $issueID is \"$issueSummary\"\n";
    -- End Perl --

     

  •  03-07-2006, 8:52 PM

    Re: HOWTO: Call web service from perl script

    I get: 500 Internal Server Error at C:\denap\Perl\gemini.pl line 55  which is the:

    my $soapResponse = $soapHandler->call($getIssue => @params);  line

    Is there a typical reason this would occur?  I think I've set the access code and url correctly...

     

    thanks,

    -Tom

  •  03-07-2006, 10:12 PM

    Re: HOWTO: Call web service from perl script

    Hi Tom,

     

    Try navigating to the web service using a browser. ie. http://localhost/gemini/webservices/Gemini.asmx

    Does it work? if yes then try to execute a method.

  •  03-09-2006, 6:29 PM

    Re: HOWTO: Call web service from perl script

    No... I get:

    Parser Error Message: The 'type' attribute must be set to a valid type name.

    Source Error:

    Line 303:		<webServices>
    Line 304:			<soapExtensionTypes>
    Line 305:				<add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Line 306:					priority="1" group="0" />
    Line 307:			</soapExtensionTypes>

    Source File: c:\inetpub\wwwroot\Gemini\web.config    Line: 305

     

  •  03-09-2006, 6:56 PM

    Re: HOWTO: Call web service from perl script

    User error... WSE was not installed. 
View as RSS news feed in XML