1
Answer

How to capture the ToArray() value from webservice to aspx.cs

Ajay Gautam

Ajay Gautam

14y
1.7k
1

Hi All,

I have one function in webservice:-

/// <summary>
        /// Get the required user agreements for the application specified.
        /// </summary>
        /// <param name="applicationName">The name of the application.</param>
        /// <returns>A UserAgreement array containing the name and text of the user agreement.</returns>
        [WebMethod]
        public UserAgreement[] GetRequiredUserAgreements(string applicationName)
        {
            List<UserAgreement> userAgreements = new List<UserAgreement>();

            KeyValuePair<string, string>[] parameters = new KeyValuePair<string, string>[1];
            KeyValuePair<string, string> parameter = new KeyValuePair<string, string>("applicationName", applicationName);
            parameters[0] = parameter;
            int returncode = Keups.Business.WebServiceAudit.RecordWebServiceAccess("InquiryService",
                this.User.Identity.Name, "GetRequiredUserAgreements", parameters);
            if (returncode != 0)
            {
                return userAgreements.ToArray();
            }
            
            Keups.Business.Application application = Keups.Business.Application.FindApplicationByName(applicationName);
            if (application != null)
            {
                Keups.Business.UserAgreement[] agreements = application.Agreements;
                foreach (Keups.Business.UserAgreement agreement in agreements)
                {
                    UserAgreement userAgreement = new UserAgreement();
                    userAgreement.AgreementName = agreement.Name;
                    userAgreement.AgreementText = agreement.Text;
                    userAgreements.Add(userAgreement);
                }
            }

            return userAgreements.ToArray();
        }

i have already registered the webservice, now i need to capture the return value in my aspx.cs page.

i tried like this

UserAgreement[] userAppAgreements = inquiry.GetRequiredUserAgreements(appName);

this is giving me error.

then i tried like this

object  userAppAgreements = inquiry.GetRequiredUserAgreements(appName);

here not able to check the null and >0 condition.

Any help?


Answers (1)