Forum Discussion

gantry_york's avatar
gantry_york
Occasional Contributor
14 years ago

Interfacing with SWPlanner web services using Perl's SOAP::Lite

Has anyone had any success interfacing to ALM/SoftwarePlanner's web services using Perl's SOAP::Lite module?



I keep getting the following error:



Server did not recognize the value of HTTP Header SOAPAction: #GetLoginInfo.
  • Hi Gantry,

    I was hoping someone with hands-on web service experience would pipe in, but no luck so far.

    If you are still having issues, would you mind submitting a ticket to our support team? Just click on Help Center at the top right of ALMComplete and then Create Support Ticket.

    If you provide exact details of what you are trying to do, they should be able to get you an answer.

    Thanks!
  • gantry_york's avatar
    gantry_york
    Occasional Contributor
    I was able to get it to work, but it took some time to figure it out.   Here is a sample program that will demonstrate how to use Perl's SOAP::Lite to talk to Software Planner.  Hopefully this will save others from having to go through as much trial and error.





    #!/usr/bin/perl



    use strict;



    use SOAP::Lite;

    use Data::Dumper; $Data::Dumper::Indent = 1;



    my $proxy = 'http://softwareplanner.mydomain.com/psWS/psWS.asmx';

    my $uri   = 'http://www.pragmaticsw.com';

    my $xmlschema = 'http://www.w3.org/2001/XMLSchema';





    sub main {



        #########################################################

        ## Starting up the SWPlanner SOAP Client

        #########################################################



        print "Starting SWPlanner SOAP Client...\n\n";



        # By default SOAP::Lite use [uri]#[method], the .NET

        # framework used by SWPlanner requires [uri]/[method]

        # This is why the on_action join is required



        my $swp = SOAP::Lite

        ->uri( $uri )

        ->on_action( sub { join '/', $uri, $_[1] } )

        ->proxy( $proxy );





        $swp->serializer->xmlschema( 'http://www.w3.org/2001/XMLSchema' );

        $swp->serializer->soapversion( '1.1' );

        $swp->serializer->envprefix( 'soap' );

        $swp->serializer->encprefix( 'soapenc' );



        #$swp->outputxml( 'true' );

        #print Dumper( $services );



        #########################################################

        ## Method requiring no arguments

        ## Output is in the result

        #########################################################



        print "Calling GetVersion...\n\n";



        my $mname = 'GetVersion';



        my $method = SOAP::Data->name( $mname )

            ->attr( {xmlns => "$uri/" } );



        my $som = $swp->call( $method );





        print Dumper ( $som->result );



        print "\n\n";







        #########################################################

        ## Method requiring multiple arguments

        ## Output is returned in a data structure

        #########################################################



        print "Calling GetLoginInfo...\n\n";



        my $mname = 'GetLoginInfo';



        my $method = SOAP::Data->name( $mname )

            ->attr( {xmlns => "$uri/" } );



        my @params = (

        SOAP::Data->name( AppCode  => 'agSPEnt' ),

        SOAP::Data->name( Email    => 'gantry.york@mydomain.com' ),

        SOAP::Data->name( Password => 'test123' )

        );



        my $som = $swp->call( $method => @params );



        print Dumper( $som );



        my $match_string = "/Enveloper/Body/$mname" . "Response/$mname" . 'Result';

        my $data = $som->match( $match_string );



        print Dumper( $data->valueof('[1]') );

        print Dumper( $data->valueof('[2]') );

        print Dumper( $data->valueof('[3]') );

        print Dumper( $data->valueof('[4]') );

        print Dumper( $data->valueof('[5]') );

        print Dumper( $data->valueof('[5]/[1]') );



        print "\n\n";







        #########################################################

        ## Method requiring Authentication

        ## Method requiring complex argument data structure

        ## output is returned in a data structure

        #########################################################



        print "Calling Releases_Load...\n\n";



        my $mname = 'Releases_Load';



        my $method = SOAP::Data->name( $mname )

            ->attr( {xmlns => "$uri/" } );



        # Notice it is PassCode in this method, not Password

        

        my @params = (

        SOAP::Data->name( AuthenticationData =>

            \SOAP::Data->value(

            SOAP::Data->name( AppCode  => 'agSPEnt' ),

            SOAP::Data->name( DeptId   => '8162' ),

            SOAP::Data->name( ProjId   => '11910' ),

            SOAP::Data->name( UserId   => '25698' ),

            SOAP::Data->name( PassCode => 'test123' ),

            SOAP::Data->name( ProjIds  =>

                \SOAP::Data->value(

                SOAP::Data->name( int => '11910' ),

                ),

            ),

            ),

        ),

        SOAP::Data->name( ReleaseId => '10' )

        );



        my $som = $swp->call( $method => @params );



        my $match_string = "/Enveloper/Body/$mname" . "Response/$mname" . 'Result';

        my $data = $som->match( $match_string );



        print Dumper( $data->valueof('[1]') );

        print Dumper( $data->valueof('[2]') );

        print Dumper( $data->valueof('[3]') );

        print Dumper( $data->valueof('[4]') );

        print Dumper( $data->valueof('[5]') );

        print Dumper( $data->valueof('[5]/[1]') );



        print "\n\n";



    }



    main();

    exit();




  • gantry_york's avatar
    gantry_york
    Occasional Contributor
    It would be nice if SmartBear would update the Web Services User's Guide with more information.



    I'm having to do a lot of trial and error to figure the required attributes of an object in order to add a record.



    For example, if the Test object only has a value for FolderId, there appears to be a stored procedure that will look up FolderName for you, so FolderName really isn't required to do a Tests_Add.





    Also some of the fault message are very sketchy.  "Internal WebService Error.  Please contact system administrator" gives me almost no indication of what went wrong.
  • gantry_york's avatar
    gantry_york
    Occasional Contributor
    Are you trying to supersize me?



    Well the documentation does list which fields are required, but it would be nice if the docs also listed which fields are populated with stored procedures.



    It would also be nice to include a UML class diagram in the docs.
  • gantry_york's avatar
    gantry_york
    Occasional Contributor
    In the Method_LoadByCriteria functions, what is the format of the 'Condition' arguement?  Is it an SQL query string?
  • KKop's avatar
    KKop
    Occasional Contributor
    This is a very late reply regarding this, but for completeness sake I guess:



    It's in the form of an xml string.  The .NET utility that you can download shows an example of it.



    BTW, you're right about the documentation.  I'm pretty sure I could figure things out by myself (my persistence overcomes my lack of intelligence :-)), if the web services guide showed a little more detail.



    I've got the basics figured out now, but it's in java, not PERL.
  • Hello Rino,



    I have recently started working on webservices.  I am trying to load all the TestRunItems in a particular testrun but am not able to get the format of conditions correctly.



    Can you please point me to some document that can help me.  The user guide gives me an idea of the required fields but no clue how to formulate conditions tag.



    Any help is highly appreciated.



    Thanks



    Sapan
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Sapan,



    Try the following value for the Condition parameter (replace 528 with your test run ID):

    <Conditions

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

        xmlns:xsd="http://www.w3.org/2001/XMLSchema"

        Operation="opEQU">

        <Items Type="tField">

            <Value xsi:type="xsd:string">TestRunId</Value>

        </Items>

        <Items Type="tConst">

            <Value xsi:type="xsd:int">528</Value>

        </Items>

    </Conditions>


    If you construct the request XML manually, put the condition string inside CDATA&colon;



    ...

    <TestRunItems_LoadByCriteria xmlns="http://www.pragmaticsw.com/">

        <AuthenticationData>

        ...

       <AuthenticationData>

       <Condition><![CDATA[

          <Conditions

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xmlns:xsd="http://www.w3.org/2001/XMLSchema"

             Operation="opEQU">

             <Items Type="tField">

                <Value xsi:type="xsd:string">TestRunId</Value>

             </Items>

             <Items Type="tConst">

                <Value xsi:type="xsd:int">528</Value>

             </Items>

          </Conditions>

       ]]></Condition>

       ...


    There's more info about conditions on pages 58 and 62 of the web service guide. Hope this helps!