}, } {endcode} + +{section: Additional Examples} + +Here are a few additional examples of using the Condor SOAP interface, this time in Perl. These examples assume that the _condor_schedd_ has been configured to run on well-known port 8080 as described above. + +{subsection: Get Version String in Perl} +{code} +use SOAP::Lite ; +my $soap = SOAP::Lite->new( + proxy => 'http://localhost:8080/soap', + default_ns => 'urn:condor' +); + + +my $som = $soap->call( + "getVersionString" +); +die $som->fault->{ faultstring } if ($som->fault); + +my %result = %{$som->result}; +print "$result{'message'}\n"; + +my $som = $soap->call( + "getPlatformString" +); +die $som->fault->{ faultstring } if ($som->fault); + +my %result = %{$som->result}; +print "$result{'message'}\n"; +{endcode} + +{subsection: Get Job Queue in Perl} +This code example will produce output similar to _condor_q -l_. An optional command line argument can pass a constraint, similar to the _-constraint_ option with condor_q. +{code} +use SOAP::Lite ; + +# +# Create a connection to the schedd +# +my $soap = SOAP::Lite->new( + proxy => 'http://localhost:8080/soap', + default_ns => 'urn:condor' +); + +# +# Invoke getJobAds() +# +my $som = $soap->call( + "getJobAds", + SOAP::Data->name('constraint')->value( $ARGV[0] || 'TRUE'), +); +die $som->fault->{ faultstring } if ($som->fault); +my %result = %{$som->result}; + +# +# For each ad returned, print all attributes +# +my @ads; +if( ref ($result{'classAdArray'}{'item'}) eq 'HASH') { + @ads = $result{'classAdArray'}{'item'}; +} else { + @ads = @{$result{'classAdArray'}{'item'}}; +} +foreach $ad_ref (@ads) { + my @ad = @{$ad_ref->{'item'}}; + foreach $attr_ref (@ad) { + my %attr = %$attr_ref; + print " $attr{'name'} = $attr{'value'} \n"; + } + print "===============================\n"; +} +{endcode}