The below code in some C# that creates and searches for an asset. Instead of using the Create method, you would need to use the Update method, but the parameters are the same.
static void Main(string[] args)
{
// attempt to login to APM
TAMServiceClient itsc = new TAMServiceClient("BasicHttpBinding_ITAMService");
ITAMHeader ithdr = new ITAMHeader();
try
{
// login and get a session/ticket
String tid = itsc.Login(ref ithdr, "uapmadmin", "uapmadmin");
}
catch (Exception ex)
{
System.Console.WriteLine("Exceptiopn on Login: " + ex.Message);
System.Console.WriteLine(ex.StackTrace);
// Since login failed, end the program
Environment.Exit(0);
}
// search for an object, in this case, an Asset
// create the asset with the atributes you want to search on
asset myasset = new asset();
myasset.serialnumber = "ABCD";
myasset.modelid = null;
myasset.assetfamilyid = null;
myasset.classkey = null;
myasset.assetname = null;
List<ITAMObject> assetCreate = new List<ITAMObject>();
assetCreate.Add(myasset);
myasset = new asset();
myasset.serialnumber = "ABCD_2";
myasset.modelid = null;
myasset.assetfamilyid = null;
myasset.classkey = null;
myasset.assetname = null;
assetCreate.Add(myasset);
itsc.Create(ref ithdr, assetCreate);
// create the SearchDefinition and criteria
SearchDefinition sd = new SearchDefinition();
Criteria sdcriteria = new Criteria();
Criterion sdcriterion = new Criterion();
//set the criterion/criteria for the search
sdcriterion.Operator = Operator.Equal; // search for matches
sdcriterion.SearchObjects = new List<ITAMObject>() { myasset }; //create the object array of what objects to search for
sdcriteria.CriteriaList = new List<Criterion>() { sdcriterion }; //set the criterion for the search
sd.Criteria = sdcriteria; // set the criteria for the search
List<ITAMObject> sdresults = null;
try
{
sdresults = itsc.Search(ref ithdr, sd);
//ITAMObject[] sdresults = itsc.Search(ref ithdr, sd);
// process the array of results. Its an array due to the fact that the serarch may have returned more than one result
// check for emtpy array which means no results
System.Console.WriteLine(sdresults.Count);
foreach (ITAMObject iobj in sdresults)
{
asset theasset = (asset)iobj;
System.Console.WriteLine(theasset.assetname);
}
}
catch (Exception ex)
{
System.Console.WriteLine("Exceptiopn on Search: " + ex.Message);
System.Console.WriteLine(ex.StackTrace);
}
// logout of the APM session
try
{
itsc.Logout(ref ithdr);
}
catch (Exception ex)
{
System.Console.WriteLine("Exceptiopn on Logout: " + ex.Message);
System.Console.WriteLine(ex.StackTrace);
// Since login failed, end the program
Environment.Exit(0);
}
}
I do not have the SOAP Envelope created by this call to share, but I hope this helps.
Also, be aware that the code above is a sample only, and would need to updated to work. An asset needs a model, and a family and class, and I have all those set to 'null' in the example, but I hope its enough to get you on the right track.
Rick