Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7877557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:24:25+00:00 2026-06-03T03:24:25+00:00

In webservice class, it will retrieve database from online and put into list: public

  • 0

In webservice class, it will retrieve database from online and put into list:

public List<List_NewsComment> allCommentList;
public void GetCommentNews( final int gCommentNewsID)
{
    Thread networkThread=new Thread(){
        @Override
        public void run(){

            try
            {
                SoapObject request= new SoapObject(NAMESPACE,get_Comment_METHOD_NAME);
                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                HttpTransportSE androidHttpTransportSE= new HttpTransportSE(URL,60000);

                request.addProperty("itemid", gCommentNewsID);
                envelope.setOutputSoapObject(request);
                androidHttpTransportSE.call(get_Comment_SOAP_ACTION, envelope);

                SoapObject result=(SoapObject)envelope.bodyIn;
                RetrieveFromSoap( result);
            }
            catch(Exception ex)
            {
                ex.printStackTrace();
            }
        }

    };
    networkThread.start();

}

public List<List_NewsComment> RetrieveFromSoap(SoapObject soap)
{
    allCommentList= new ArrayList<List_NewsComment>();
    Vector<Object> property2 = extracted(soap);

    for (int i = 0; i< property2.size();i++){

        SoapObject getPropertyD=(SoapObject)property2.get(i);


        List_NewsComment addcomment= new List_NewsComment();
        addcomment.setcommentDate(getPropertyD.getProperty("date").toString());
        addcomment.setUserName( getPropertyD.getProperty("name").toString());
        addcomment.setCommentContent(getPropertyD.getProperty("comment").toString());

        allCommentList.add(addcomment);
    }
    webservice.allCommentList.size();        <-- can call here no problem
    return allCommentList;
}

private static Vector<Object> extracted(SoapObject soap) {
    return (Vector<Object>)soap.getProperty(0);
}

In Main Activity class, i want to check the size of list:

Database_WebService webservice = new Database_WebService(this);
    webservice.GetCommentNews(newsid);
webservice.allCommentList.size();            <-- cannot call here, what is the problem

It returns me nullpointerexception.

What is the problem????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:24:26+00:00Added an answer on June 3, 2026 at 3:24 am

    Make your List static so you can access it anywhere using that class name .

    Like

    public static List<List_NewsComment> allCommentList;
    Database_WebService.allCommentList.size();
    

    Or

    As everyone suggest make one function in your class and return the size of array in that function. Please see code below.

    public int getCommentListSize()
    {
        return allCommentList.size(); 
    }
    
    then call this method as
    
    Database_WebService databaseWebservice = new Database_WebService(this);   
    int size =databaseWebservice.getCommentListSize.size(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am accessing a class from my webservice as [WebMethod(EnableSession = true)] public string fetchAbsentees(string
I have an simple class that I get from a webservice. public class person
I'm using WebService class with WSDL. How to list available operations in WSDL and
I wrote a simple Webservice as below in Netbeans. @WebService() public class CRSEncryptString {
Simple WebSevice @WebService @Stateless public class HistoryFormatterWebService implements IHistoryFormatterWebService { @EJB private IHistoryFormatter historyFormatter;
I have a webservice [Serializable] public class DataObject { public int ID { get;
I attempt to use webservice return POCO class generated from entity data model as
I am looking for a framework to turn given Java class into WebService (may
I got a class like this which gets returned from an ASP webservice: class
I have a webservice class that will be in a managed package and distributed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.