CA Service Management

  • 1.  ITAM webservice usage

    Posted Feb 02, 2017 11:46 AM

    Hi, I have managed to use the webservices for ITAM using powershell.

    (if you change in the script below the operator to equal and the pcname0% to the exact PCname, it will find your record)

     

    However, now I am trying to search for a partial name, I am expecting to see multiple records to be returned:

     

     

     

    $URL = "C:\itam\DEV\ITAM0.wsdl"

    $usd = New-WebServiceProxy -uri $URL

    $iSID = $usd.login("username","password")

    if ($? -eq $False)

    {

    write-host "Failed to connect to USD environment so stopping script"

    exit

    }

     

    $asset = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.asset

    $sd = new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.SearchDefinition

    $sdcriteria=new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.Criteria
    $sdcriterion=new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl.Criterion

      

    $asset.assetname = "pcname0%"

    $sdcriterion.Operator = "Like"

    $sdcriterion.SearchObjects = $asset

    $sdcriteria.CriteriaList = $sdcriterion

    $sd.Criteria = $sdcriteria

    $AssetResult = $usd.search($sd)

    foreach ($pc in $AssetResult)

    {

    $pc

    }

    $usd.logout()

     

    I can also update the asset and then push the update to ITAM, so making progress  
    but you see the example above already, I am trying to use the operator "like"  (it is accepted - match or contains throws an error)  but it never returns any data while I know it should return 2 records when it search from the console....

    but the documentation is painfully limited... I have 4 examples and ITAM shows 4 examples but just one search, one create, one delete and one update. and the search is using the equal option....

     

    I would like to be able to use wildcards, it will be especially useful when searching for things like Operating System, or vendor etc...

     

     

    I do get an error - which then shows valid operators:

    Specify one of the following enumerator names and try again: Equal, NotEqual, Like, NotLike, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual, Between, NotBetween, In, NotIn, IsNull, IsNotNull, None

    so Like is a proper operator...

     

    any suggestions are welcome



  • 2.  Re: ITAM webservice usage

    Posted Feb 02, 2017 03:09 PM

    Hi Andre,

    I'm not a powershell guru, but take a look at this site:  

    Windows PowerShell Conditional Operators -match, -like -contains  

    There are quite a few examples of using -like and -contains (although the author here does not appear to be a fan of the -contains operator).   See if this help!

     

    Best Regards,

    Gale Bacon

    CA Technologies



  • 3.  Re: ITAM webservice usage

    Posted Feb 03, 2017 03:36 AM

    It is the search function and operator provided by the webservice, so it's not related to the "normal" powershell operators.

     

    I don't need a specific powershell example, a C#  or Soap example is fine too.

    right now there is no documentation at all that shows how to use Like operator (and how to use/place wildcards)  - the only example available is Equal. no other examples or details are provided. I have tried to search the CA bookshelves, but I have not been able to find documentation that goes into more detail on the webservices. if you know any, could you provide links to it ??

     

    I have tried *  and % and no wildcards at all, but I never get a result. only a 100% match works..



  • 4.  Re: ITAM webservice usage
    Best Answer

    Broadcom Employee
    Posted Feb 03, 2017 11:04 AM

    Hi Andre, does the below piece of SOAP call help? It uses the operator 'like' and wildcard '%':

     

                                     <a:CriteriaList>

                                                   <a:Criterion>

                                                     <a:FieldstoNull i:nil="true" xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />

                                                     <a:Connector>None</a:Connector>

                                                     <a:Operator>Like</a:Operator>

                                                     <a:SearchObjects>

                                                                   <a:ITAMObject i:type="b:asset" xmlns:b="http://schemas.datacontract.org/2004/07/CA/ITAM/Service/DataModel/BAAAAAA">

                                                                     <b:assetname>138%</b:assetname>

                                                                   </a:ITAMObject>

                                                     </a:SearchObjects>

                                                   </a:Criterion>

                                     </a:CriteriaList>



  • 5.  Re: ITAM webservice usage

    Posted Feb 06, 2017 06:32 AM

    I got it working

     

    $asset.assetname = "138%"
    $sdcriterion.Operator = "like"
    $sdcriterion.OperatorSpecified = $true
    $sdcriterion.SearchObjects = $asset
    $sdcriteria.CriteriaList = $sdcriterion
    $sdcriteria.OperatorSpecified = $true

     

    I added the line in bold, and that "fixed" the issue...

    I noticed this also in creating or updating a record, some of the fields have this xxxxxxxSpecified  field, which you have to set to true otherwise the change is not applied for that field.

     

    i.e. below is one of the records returned. here you also see the xxxxSpecified field set to true.

    acquiredateSpecified : False

    altassetid :

    alternatehostname :

    assetalias :

    assetfamilyid : 400016

    assetfamilyidSpecified : True

     

    I am pretty sure this also has to be applied to C# scripts, as I am basically using the same classes / methods as they do in C#

     

    Thanks for the quick response. it wasn't the solution, but it proved that I was on the right way



  • 6.  Re: ITAM webservice usage

    Posted Feb 07, 2017 01:16 PM

    Hi Andre,

    Thanks for your post, we had pretty much the same question but you were quicker to publish it :-)

     

    We had earlier a similar question about APM web services and there's a TEC-doc (TEC1613719) for it here:

    ITAM web service API - ITAMObject does not return a list: http://cainc.to/60CoeF

     

    We have been asking CA support for any additional documentation for the APM web services but there does not seem to be much more than what comes built into APM.

     

    Best regards,

    Heikki Ikonen
    System Architect
    Netgain



  • 7.  Re: ITAM webservice usage

    Posted Feb 06, 2017 08:06 AM

    oh just in addition for those who are interested to use it.

    I stored the WSDL that I downloaded in C:\ITAM\DEV  and you see that coming back in the object definition too:

    Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1file____C__itam_DEV_ITAM0_wsdl

    so the easiest way to get your right path is to create / run the webservice proxy:    $usd = New-WebServiceProxy -uri $URL

    and then on the powershell commandline:

    new-object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes   when you add a . (dot)  to the end it will autoresolve and offer you the next options with the right path



  • 8.  Re: ITAM webservice usage

    Posted Feb 06, 2017 06:40 PM

    HI Andre,

     

    Very glad it's working and thanks for the extra tips! 

     

    Best Regards,

    Gale Bacon

    CA Technologies