Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use strict;
- no strict "refs";
- use Data::Dumper;
- use IO::Socket::SSL qw (SSL_VERIFY_NONE) ;
- use SOAP::Lite;
- use Tie::IxHash;
- # Username and Password
- my $sUID = "<API UserID>";
- my $sPWD = "<API Password>";
- # WSDL definition URI. Using a cached local copy using file:/... also works
- my $LookupService_wsdl = 'https://melcapi01.soc.ipsec.net.au/LogRhythm.API/Services/LookupServiceBasicAuth.svc?singleWsdl';
- my $lrns = 'http://www.logrhythm.com/webservices';
- # Ensure that a consistent xmlns:soap value is used, without this we get inconsistent results.
- $SOAP::Constants::PREFIX_ENV = 'SOAP-ENV';
- # Don't validate SSL Certificate while testing
- IO::Socket::SSL::set_defaults(SSL_verify_mode => "SSL_VERIFY_NONE");
- # Construct the security header
- my %authHash;
- tie %authHash, "Tie::IxHash";
- %authHash = (
- Username => SOAP::Data->type( '' => $sUID )->prefix('wsse'),
- Password => SOAP::Data->type( '' => $sPWD )->prefix('wsse'),
- );
- my $wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
- my $securityHeader = SOAP::Header->new(
- name => 'Security',
- uri => $wsse,
- prefix => 'wsse',
- value => SOAP::Data->new(
- name => 'UsernameToken',
- prefix => 'wsse',
- value => %authHash,
- )
- );
- # Error handling
- on_fault => sub { my($soap, $res) = @_;
- die ref $res ? $res->faultstring : $soap->transport->status;
- };
- # Define the SOAP Instance
- my $lrapi = SOAP::Lite
- -> readable (1)
- -> service($LookupService_wsdl)
- -> on_action( sub {return $action});
- # Set the default Namespace
- $lrapi->default_ns($lrns);
- # Actually get data from the LookupService
- my $result;
- # Build up the parameters
- my @classificationType = ( SOAP::Data->new(name =>'classificationType', value => 2000));
- $result = $lrapi->GetClassificationsByType($securityHeader);
- print Dumper $result;
- SOAPAction: "http://www.logrhythm.com/webservices/LookupService/GetClassificationsByType"
- <?xml version="1.0" encoding="UTF-8"?>
- <SOAP-ENV:Envelope
- SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:tns="http://www.logrhythm.com/webservices"
- xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
- xmlns:wsa10="http://www.w3.org/2005/08/addressing"
- xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
- xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
- xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
- xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
- xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
- xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <SOAP-ENV:Header>
- <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
- <wsse:UsernameToken>
- <wsse:Username>reporting</wsse:Username>
- <wsse:Password>password</wsse:Password>
- </wsse:UsernameToken>
- </wsse:Security>
- </SOAP-ENV:Header>
- <SOAP-ENV:Body>
- <tns:GetClassificationsByType>
- <classificationType xsi:type="xsd:int">2000</classificationType>
- <classificationTypeSpecified xsi:type="xsd:boolean">true</classificationTypeSpecified>
- </tns:GetClassificationsByType>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
- SOAPAction: "http://www.logrhythm.com/webservices/LookupService/GetClassificationsByType"
- <?xml version="1.0" encoding="UTF-8"?>
- <SOAP-ENV:Envelope
- SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:tns="http://www.logrhythm.com/webservices"
- xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
- xmlns:wsa10="http://www.w3.org/2005/08/addressing"
- xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
- xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
- xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
- xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
- xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
- xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <SOAP-ENV:Header>
- <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
- <wsse:UsernameToken>
- <wsse:Username>reporting</wsse:Username>
- <wsse:Password>password</wsse:Password>
- </wsse:UsernameToken>
- </wsse:Security>
- </SOAP-ENV:Header>
- <SOAP-ENV:Body>
- <tns:GetClassificationsByType xmlns="http://www.logrhythm.com/webservices">
- <classificationType xsi:type="xsd:int">2000</classificationType>
- <classificationTypeSpecified xsi:type="xsd:boolean">true</classificationTypeSpecified>
- </tns:GetClassificationsByType>
- </SOAP-ENV:Body>
- </SOAP-ENV:Envelope>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement