Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.94 KB | None | 0 0
  1. use strict;
  2. no strict "refs";
  3.  
  4. use Data::Dumper;
  5. use IO::Socket::SSL qw (SSL_VERIFY_NONE) ;
  6. use SOAP::Lite;
  7. use Tie::IxHash;
  8.  
  9. # Username and Password
  10. my $sUID = "<API UserID>";
  11. my $sPWD = "<API Password>";
  12.  
  13. # WSDL definition URI. Using a cached local copy using file:/... also works
  14. my $LookupService_wsdl = 'https://melcapi01.soc.ipsec.net.au/LogRhythm.API/Services/LookupServiceBasicAuth.svc?singleWsdl';
  15. my $lrns = 'http://www.logrhythm.com/webservices';
  16.  
  17. # Ensure that a consistent xmlns:soap value is used, without this we get inconsistent results.
  18. $SOAP::Constants::PREFIX_ENV = 'SOAP-ENV';
  19.  
  20. # Don't validate SSL Certificate while testing
  21. IO::Socket::SSL::set_defaults(SSL_verify_mode => "SSL_VERIFY_NONE");
  22.  
  23. # Construct the security header
  24. my %authHash;
  25. tie %authHash, "Tie::IxHash";
  26. %authHash = (
  27. Username => SOAP::Data->type( '' => $sUID )->prefix('wsse'),
  28. Password => SOAP::Data->type( '' => $sPWD )->prefix('wsse'),
  29. );
  30.  
  31. my $wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
  32. my $securityHeader = SOAP::Header->new(
  33. name => 'Security',
  34. uri => $wsse,
  35. prefix => 'wsse',
  36. value => SOAP::Data->new(
  37. name => 'UsernameToken',
  38. prefix => 'wsse',
  39. value => %authHash,
  40. )
  41. );
  42.  
  43. # Error handling
  44. on_fault => sub { my($soap, $res) = @_;
  45. die ref $res ? $res->faultstring : $soap->transport->status;
  46. };
  47.  
  48. # Define the SOAP Instance
  49. my $lrapi = SOAP::Lite
  50. -> readable (1)
  51. -> service($LookupService_wsdl)
  52. -> on_action( sub {return $action});
  53.  
  54. # Set the default Namespace
  55. $lrapi->default_ns($lrns);
  56.  
  57. # Actually get data from the LookupService
  58. my $result;
  59.  
  60. # Build up the parameters
  61. my @classificationType = ( SOAP::Data->new(name =>'classificationType', value => 2000));
  62.  
  63. $result = $lrapi->GetClassificationsByType($securityHeader);
  64.  
  65. print Dumper $result;
  66.  
  67. SOAPAction: "http://www.logrhythm.com/webservices/LookupService/GetClassificationsByType"
  68.  
  69. <?xml version="1.0" encoding="UTF-8"?>
  70. <SOAP-ENV:Envelope
  71. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  72. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  73. xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
  74. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  75. xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
  76. xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  77. xmlns:tns="http://www.logrhythm.com/webservices"
  78. xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
  79. xmlns:wsa10="http://www.w3.org/2005/08/addressing"
  80. xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
  81. xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
  82. xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
  83. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  84. xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
  85. xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
  86. xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
  87. xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  88. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  89. <SOAP-ENV:Header>
  90. <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
  91. <wsse:UsernameToken>
  92. <wsse:Username>reporting</wsse:Username>
  93. <wsse:Password>password</wsse:Password>
  94. </wsse:UsernameToken>
  95. </wsse:Security>
  96. </SOAP-ENV:Header>
  97. <SOAP-ENV:Body>
  98. <tns:GetClassificationsByType>
  99. <classificationType xsi:type="xsd:int">2000</classificationType>
  100. <classificationTypeSpecified xsi:type="xsd:boolean">true</classificationTypeSpecified>
  101. </tns:GetClassificationsByType>
  102. </SOAP-ENV:Body>
  103. </SOAP-ENV:Envelope>
  104.  
  105. SOAPAction: "http://www.logrhythm.com/webservices/LookupService/GetClassificationsByType"
  106.  
  107. <?xml version="1.0" encoding="UTF-8"?>
  108. <SOAP-ENV:Envelope
  109. SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  110. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  111. xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
  112. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  113. xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
  114. xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  115. xmlns:tns="http://www.logrhythm.com/webservices"
  116. xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
  117. xmlns:wsa10="http://www.w3.org/2005/08/addressing"
  118. xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
  119. xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
  120. xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
  121. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  122. xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
  123. xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
  124. xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
  125. xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  126. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  127. <SOAP-ENV:Header>
  128. <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
  129. <wsse:UsernameToken>
  130. <wsse:Username>reporting</wsse:Username>
  131. <wsse:Password>password</wsse:Password>
  132. </wsse:UsernameToken>
  133. </wsse:Security>
  134. </SOAP-ENV:Header>
  135. <SOAP-ENV:Body>
  136. <tns:GetClassificationsByType xmlns="http://www.logrhythm.com/webservices">
  137. <classificationType xsi:type="xsd:int">2000</classificationType>
  138. <classificationTypeSpecified xsi:type="xsd:boolean">true</classificationTypeSpecified>
  139. </tns:GetClassificationsByType>
  140. </SOAP-ENV:Body>
  141. </SOAP-ENV:Envelope>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement