SOAP API CALL FROM PERL

Not Yet Reviewed

I am not able to find the parameters of method FindWhoIsOnDuty . I am using perl programming to connect the xmatter. Nowhere I see the useful information on API calls in this document. Please help me to understand how it works.

0

Comments

4 comments
Date Votes

Please sign in to leave a comment.

  • Hey Kalaiselvan, I think I have something that you might find interesting. This was coded using our xMatters On Demand platform, but if you're using on premise I think you'll just need to change the schema entries to be appropriate for your version. In theory the rest of it should work fine. Give this a whirl and let us know how it goes:

    declare usage of SOAP::Lite

    use SOAP::Lite; # +trace; #trace allows for seeing the full Request and Response sent back and forth

    my $username = 'ws_user';
    my $password = 'password';
    my $endpoint = 'https://company.instance.xmatters.com/api/services/xmatters-5.5.47.xmatters-5.5.47HttpSoap12Endpoint/';
    my $operation = 'FindWhoIsOnDuty';
    my $company = 'company';
    my $group = 'Test Group';
    my $start = '09/11/2014 12:00:00 AM';
    my $end = '09/12/2014 12:00:00 AM';
    my $reciDetails = 'false';

    declare the SOAP endpoint here

    my $soap = SOAP::Lite
    ->new( proxy => $endpoint );

    $soap->autotype(0);
    $soap->default_ns( 'http://www.xmatters.com/webservices/schema#5.5.47' );
    $soap->ns( 'http://www.xmatters.com/webservices/schema#5.5.47', 'sch' );
    $soap->on_fault(
    sub { # SOAP fault handler
    my $soap = shift;
    my $res = shift;

    # Map faults to exceptions
    if ( ref($res) eq '' ) {
      die("res: " . $res . " status: " . $soap->transport->http_response->content() );
    }
    else {
      die( $res->faultstring );
    }
    return new SOAP::SOM;
    

    }
    );

    invoke the SOAP call

    my $result = $soap->call( "sch:" . $operation,
    SOAP::Data->name('sch:user')->value( $username ),
    SOAP::Data->name('sch:password')->value( $password ),
    SOAP::Data->name('sch:clientTimestamp')->value( '' ),
    SOAP::Data->name('sch:clientIP')->value( '' ),
    SOAP::Data->name('sch:clientOSUser')->value( '' ),
    SOAP::Data->name('sch:company')->value( $company ),
    SOAP::Data->name('sch:groupName')->value( $group ),
    SOAP::Data->name('sch:startDate')->value( $start ),
    SOAP::Data->name('sch:endDate')->value( $end ),
    SOAP::Data->name('sch:includeRecipientDetails')->value( $reciDetails )
    );

    #die $result->Fault->{ Reason } if ($result->Fault);
    print "result: ", $result, "\n";

    while( my( $key, $value ) = each $result->valueof( '//return' ) ){
    print "$key: $value\n";
    }

    0
  • Wow, that was totally butchered... take 2?

    # declare usage of SOAP::Lite
    use SOAP::Lite; # +trace;  #trace allows for seeing the full Request and Response sent back and forth
    
    my $username = 'ws_user';
    my $password = 'password';
    my $endpoint = 'https://company.instance.xmatters.com/api/services/xmatters-5.5.47.xmatters-5.5.47HttpSoap12Endpoint/';
    my $operation = 'FindWhoIsOnDuty';
    my $company   = 'company';
    my $group    = 'Test Group';
    my $start    = '09/11/2014 12:00:00 AM';
    my $end      = '09/12/2014 12:00:00 AM';
    my $reciDetails = 'false';
    
    
    # declare the SOAP endpoint here
    my $soap = SOAP::Lite
        ->new( proxy => $endpoint );
    
    $soap->autotype(0);
    $soap->default_ns( 'http://www.xmatters.com/webservices/schema#5.5.47' );
    $soap->ns( 'http://www.xmatters.com/webservices/schema#5.5.47', 'sch' );
    $soap->on_fault(
      sub {    # SOAP fault handler
        my $soap = shift;
        my $res  = shift;
    
        # Map faults to exceptions
        if ( ref($res) eq '' ) {
          die("res: " . $res . " status: " . $soap->transport->http_response->content() );
        }
        else {
          die( $res->faultstring );
        }
        return new SOAP::SOM;
      }
    );
    
    
    
    # invoke the SOAP call
    my $result = $soap->call( "sch:" . $operation,
     SOAP::Data->name('sch:user')->value( $username ),
     SOAP::Data->name('sch:password')->value( $password ),
     SOAP::Data->name('sch:clientTimestamp')->value( '' ),
     SOAP::Data->name('sch:clientIP')->value( '' ),
     SOAP::Data->name('sch:clientOSUser')->value( '' ),
     SOAP::Data->name('sch:company')->value( $company ),
     SOAP::Data->name('sch:groupName')->value( $group ),
     SOAP::Data->name('sch:startDate')->value( $start ),
     SOAP::Data->name('sch:endDate')->value( $end ),
     SOAP::Data->name('sch:includeRecipientDetails')->value( $reciDetails )
    );
    
    
    
    #die $result->Fault->{ Reason } if ($result->Fault);
    print "result: ", $result, "\n";
    
    while( my( $key, $value ) = each $result->valueof( '//return' ) ){
        print "$key: $value\n";
    }
    
    0
  • 0
  • That should work in theory, but I would encourage going with the latest wsdl endpoint you have. Check the Accessing Web Services. If you are using on demand, then i would encourage this one: https://company.instance.xmatters.com/api/services/xmatters-5.5.47.xmatters-5.5.47HttpSoap12Endpoint/

    0

Didn't find what you were looking for?

New post