Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
616 views

Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

Hi All,

I am working on an method to do SNMP walk via NNMi API I used following URL https://NNMiSERVER/SnmpBeanService/SnmpBean?wsdl, I did populate the following fields 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:snmp="http://snmp.sdk.nms.ov.hp.com/">
<soapenv:Header/>
<soapenv:Body>
<snmp:snmpGet>
<arg0>
<!--Zero or more repetitions:-->
<item></item>
</arg0>
<arg1>
<!--Zero or more repetitions:-->
<item></item>
</arg1>
<arg2>
<!--Optional:-->
<managementAddress>DeviceIPAddress</managementAddress>
<!--Optional:-->
<msTimeout>59000</msTimeout>
<!--Optional:-->
<retries>2</retries>
<!--Optional:-->
<snmpPort>161</snmpPort>
<!--Optional:-->
<snmpProxyAddress></snmpProxyAddress>
<!--Optional:-->
<snmpProxyPort>-1</snmpProxyPort>
<!--Optional:-->
<snmpProxyTargetVarbindEnabled>false</snmpProxyTargetVarbindEnabled>
<!--Optional:-->
<snmpVersion>2</snmpVersion>
<!--Optional:-->
<v2ReadCommunityString>DEVICESNMPString</v2ReadCommunityString>
<!--Optional:-->
<v2WriteCommunityString></v2WriteCommunityString>
<!--Optional:-->
<v3Config>
<!--Optional:-->
<authPassphrase></authPassphrase>
<!--Optional:-->
<authProtocol></authProtocol>
<!--Optional:-->
<contextName></contextName>
<!--Optional:-->
<privPassphrase></privPassphrase>
<!--Optional:-->
<privProtocol></privProtocol>
<!--Optional:-->
<userName></userName>
</v3Config>
</arg2>
</snmp:snmpGet>
</soapenv:Body>
</soapenv:Envelope>

When I executed it I got below error,

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>SNMP service failure. Message: Empty textualOid caused by javax.ejb.EJBTransactionRolledbackException: Empty textualOid</faultstring>
<detail>
<snmp:NmsSnmpFault xmlns:snmp="http://snmp.sdk.nms.ov.hp.com/">
<message>SNMP service failure. Message: Empty textualOid</message>
</snmp:NmsSnmpFault>
</detail>
</env:Fault>
</env:Body>
</env:Envelope>

I am not sure what I missed here, I checked the credentials are correct and I can pull node information using other API interface.

NNMi Version 10.20.280

Regards,

Naresh

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

Hi Naresh,

  Firstly please ensure you have the latest 10.20 Patch installed.  It does deliver a fix to this bean in respect of the 3rd argument.   However, the error you are getting appears to be because you have not provided arguments 1 and 2 ( the MIB OID you want to retreive and the host you want to retrieve it from ).   I am not SDK programmer, but when I was looking into the error above the Soap request I was using was:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:snmp="http://snmp.sdk.nms.ov.hp.com/">
<soapenv:Header/>
<soapenv:Body>
<snmp:snmpGet>
            <arg0><item>.1.3.6.1.2.1.1.2.0</item></arg0>
            <arg1><item>15.xxx.yyy.zzz</item></arg1>
            <arg2></arg2>
</snmp:snmpGet>
</soapenv:Body>
</soapenv:Envelope>

  While Arg2 should be allowed to be blank it was causing an error.

  Hope this helps ( if it does not then I would suggest opening a support case so we can help resolve the issue ).

Dave Y

MicroFocus Support
Viewed the Support tips? Search for "(NNMi) Support Tips" and order by Date to get the list
The views expressed in my contributions are my own and do not necessarily reflect the views and strategy of MicroFocus
If you find this or any post resolves your issue, please be sure to mark it as an accepted solution.

View solution in original post

7 Replies
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

Hi All,

Please help me on this issue.

Regards,

Naresh

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

Hi Naresh,

  Firstly please ensure you have the latest 10.20 Patch installed.  It does deliver a fix to this bean in respect of the 3rd argument.   However, the error you are getting appears to be because you have not provided arguments 1 and 2 ( the MIB OID you want to retreive and the host you want to retrieve it from ).   I am not SDK programmer, but when I was looking into the error above the Soap request I was using was:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:snmp="http://snmp.sdk.nms.ov.hp.com/">
<soapenv:Header/>
<soapenv:Body>
<snmp:snmpGet>
            <arg0><item>.1.3.6.1.2.1.1.2.0</item></arg0>
            <arg1><item>15.xxx.yyy.zzz</item></arg1>
            <arg2></arg2>
</snmp:snmpGet>
</soapenv:Body>
</soapenv:Envelope>

  While Arg2 should be allowed to be blank it was causing an error.

  Hope this helps ( if it does not then I would suggest opening a support case so we can help resolve the issue ).

Dave Y

MicroFocus Support
Viewed the Support tips? Search for "(NNMi) Support Tips" and order by Date to get the list
The views expressed in my contributions are my own and do not necessarily reflect the views and strategy of MicroFocus
If you find this or any post resolves your issue, please be sure to mark it as an accepted solution.

View solution in original post

Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

Thanks a lot, Dave.

I tried the same method on my end and it worked.

If anyone trying to perform NNMi SOAP access using PowerShell use the below script to trigger so.

 

 

$Url = "https://NNMiSERVER/SnmpBeanService/SnmpBean?wsdl"
if (-not ([System.Management.Automation.PSTypeName]'TrustAllCertsPolicy').Type) {
    Add-Type -TypeDefinition @"
        using System.Net;
        using System.Security.Cryptography.X509Certificates;
        public class TrustAllCertsPolicy : ICertificatePolicy {
            public bool CheckValidationResult(
                ServicePoint srvPoint, X509Certificate certificate,
                WebRequest request, int certificateProblem) {
                return true;
            }
        }
"@
}
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy -ErrorAction SilentlyContinue
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$nnmipassword = 'NNMIPASSWORD' | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object pscredential -ArgumentList ('NNMIUSERNAME' , $nnmipassword)
$Connect_Body = @"
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:snmp="http://snmp.sdk.nms.ov.hp.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <snmp:snmpGetNext>
         <arg0>
            <item>.1.3.6.1.2.1.1.1.0</item>
         </arg0>
         <arg1>
            <item>DEVICEIPADDRESS</item>
         </arg1>
         <arg2>
            <managementAddress></managementAddress>
            <msTimeout>59</msTimeout>
            <retries>1</retries>
            <snmpPort>161</snmpPort>
            <snmpProxyAddress></snmpProxyAddress>
            <snmpProxyPort></snmpProxyPort>
            <snmpProxyTargetVarbindEnabled></snmpProxyTargetVarbindEnabled>
            <snmpVersion>2</snmpVersion>
            <v2ReadCommunityString>DEVICECOMMUNITYSTRING</v2ReadCommunityString>
            <v2WriteCommunityString></v2WriteCommunityString>
            <v3Config>
                  <authPassphrase></authPassphrase>
                  <authProtocol></authProtocol>
                  <contextName></contextName>
                  <privPassphrase></privPassphrase>
                  <privProtocol></privProtocol>
                  <userName></userName>
            </v3Config>
         </arg2>
      </snmp:snmpGetNext>
   </soapenv:Body>
</soapenv:Envelope>
"@
$Connect_Params = @{
    Uri         = $Url
    Body        = $Connect_Body
    Method      = 'POST'
    Headers     = @{
        SOAPAction = 'snmpGetNext'
    }
    ContentType = 'text/xml;charset=UTF-8'
}
try {
    $RetrieveQueryResults_Request = Invoke-WebRequest @Connect_Params -Credential $Credentials -UseBasicParsing
    $RetrieveQueryResults_Response = [xml]($RetrieveQueryResults_Request)
    $response = $RetrieveQueryResults_Response.Envelope.Body.snmpGetNextResponse.return.item.snmpConfig.managementAddress
}
catch {
    $result = $_.Exception.Response.GetResponseStream()
    $reader = New-Object System.IO.StreamReader($result)
    $reader.BaseStream.Position = 0
    $reader.DiscardBufferedData()
    $responseBody = $reader.ReadToEnd();
    $extractxml = [xml]$responseBody
    $response = $extractxml.Envelope.body.fault.faultstring
}
$response

 

Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

I am glad what little I know was of help.

  All the best

Dave Y

MicroFocus Support
Viewed the Support tips? Search for "(NNMi) Support Tips" and order by Date to get the list
The views expressed in my contributions are my own and do not necessarily reflect the views and strategy of MicroFocus
If you find this or any post resolves your issue, please be sure to mark it as an accepted solution.
0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

Hi Dave, I am trying the same using SNMP v3 enabled devices. Could you please let me know the missing inputs from the below SNMPBean request.

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:snmp="http://snmp.sdk.nms.ov.hp.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <snmp:snmpGetNext>
         <arg0>
            <!--Zero or more repetitions:-->
            <item>.1.3.6.1.2.1.1.1.0</item>
         </arg0>
         <arg1>
            <!--Zero or more repetitions:-->
            <item>10.0.0.1</item>
         </arg1>
         <arg2>
            <!--Optional:-->
            <managementAddress>10.0.0.1</managementAddress>
            <!--Optional:-->
            <msTimeout>59</msTimeout>
            <!--Optional:-->
            <retries>1</retries>
            <!--Optional:-->
            <snmpPort>161</snmpPort>
            <!--Optional:-->
            <snmpProxyAddress></snmpProxyAddress>
            <!--Optional:-->
            <snmpProxyPort></snmpProxyPort>
            <!--Optional:-->
            <snmpProxyTargetVarbindEnabled></snmpProxyTargetVarbindEnabled>
            <!--Optional:-->
            <snmpVersion>3</snmpVersion>
            <!--Optional:-->
            <v2ReadCommunityString></v2ReadCommunityString>
            <!--Optional:-->
            <v2WriteCommunityString></v2WriteCommunityString>
            <!--Optional:-->
            <v3Config>
               <!--Optional:-->
               <authPassphrase>Public!</authPassphrase>
               <!--Optional:-->
               <authProtocol>HMAC_MD5_96</authProtocol>
               <!--Optional:-->
               <contextName>1</contextName>
               <!--Optional:-->
               <privPassphrase>Public!</privPassphrase>
               <!--Optional:-->
               <privProtocol>DES_CBC</privProtocol>
               <!--Optional:-->
               <userName>NETUSER</userName>
            </v3Config>
         </arg2>
      </snmp:snmpGetNext>
   </soapenv:Body>
</soapenv:Envelope>
0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

I got following error not sure why.

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>java.util.NoSuchElementException</faultstring>
</env:Fault>
</env:Body>
</env:Envelope>

0 Likes
Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: Unable to run SNMPGet using snmpbean SOAP API

Jump to solution

Figured it out.

Following filed should not be left empty.  Put some value and it works.

<v2ReadCommunityString>Somedata</v2ReadCommunityString>

Regards,

Naresh

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.