Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Retrieving Device Count for a Server

I am looking for some sample code which can help me retrieve Total No. of Devices registered on a Server /Farm.

I tried using the Stored Query Example.

public static string serverCapacity_StoredQuery()
        {
            //String contextId = Guid.NewGuid().ToString();
            AfariaStoredQueriesService.StoredQueriesServiceClient svcStoredQueries = null;
            try
            {

                //string apiAddress = "172.18.1.**";
                svcStoredQueries = new AfariaStoredQueriesService.StoredQueriesServiceClient("WSHttpBinding_IStoredQueriesService");
                svcStoredQueries.ClientCredentials.Windows.ClientCredential.Domain = afariaDomain;
                svcStoredQueries.ClientCredentials.Windows.ClientCredential.UserName = afariaUser;
                svcStoredQueries.ClientCredentials.Windows.ClientCredential.Password = afariaPassword;
                svcStoredQueries.InitContext(Guid.NewGuid().ToString());
                svcStoredQueries.SetTenantIdContext(0);

                AfariaStoredQueriesService.DataState state = new AfariaStoredQueriesService.DataState();
                StoredQueryFilter filter = new StoredQueryFilter();
                filter.QueryId = 1427;
                filter.DoNotAddTenantId = true;
                filter.TenantIdOverride = -1;
                filter.StartRow = -1;
                filter.MaxRows = 5000;

                filter.NameValueLists = new FilterNameValueList[1];
                filter.NameValueLists[0] = new FilterNameValueList();
                filter.NameValueLists[0].VariableName = "nvwh_mkr_filter";
                filter.NameValueLists[0].NameValueListEntries = new FilterNameValueEntry[1];
                filter.NameValueLists[0].NameValueListEntries[0] = new FilterNameValueEntry();
                filter.NameValueLists[0].NameValueListEntries[0].ColumnName = "";
                filter.NameValueLists[0].NameValueListEntries[0].DataType = "string";
                filter.NameValueLists[0].NameValueListEntries[0].DataValue = "%" + "" + "%";
                filter.NameValueLists[0].NameValueListEntries[0].Operator = "like";
                filter.NameValueLists[0].NameValueListEntries[0].Connector = "";

                DataSetSurrogate dss = svcStoredQueries.GetFirstStoredQueryFiltered(filter, out state);

                return (dss.ToString());
            }
            finally
            {
                if (svcStoredQueries != null)
                {
                    svcStoredQueries.Close();// Shared, so don't CloseContext()
                    svcStoredQueries = null;
                }
            }

        }

Seems this is not solving my issue. Also I am getting the following error, Please suggest.

  1. System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace:

   at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)

Exception rethrown at [0]:

   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

   at System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)

   at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout)

   at System.ServiceModel.ClientBase`1.Close()

   at SAPAfariaProxy.ApiHelper.serverCapacity_StoredQuery() in c:\Sap\Sources - Working Code - 17\SAPAfariaProxy\SAPAfariaProxy\ApiHelper.cs:line 1057

   at SAPAfariaProxy.WebServices.SAPAfariaProxyService.deviceCount() in c:\Sap\Sources - Working Code - 17\SAPAfariaProxy\SAPAfariaProxy\WebServices\SAPAfariaProxyService.asmx.cs:line 95

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question