2

assume in visual studio i have a method :

    [WebMethod]
    public List<PhongTro> GetAllLodgingHousesByAddress(string address)
    {
        return db.GetAllLodgingHousesByAddress(address);
    }

How to convert return data type to a ArrayList in android?


Does the following code work for you?

import nltk
WhitespaceTokenizer = nltk.WhitespaceTokenizer
WordPunctTokenizer = nltk.WordPunctTokenizer

Which version of nltk are you using? Try to update to the latest version. Your code works on my configuration (Python 2.7 with nltk 2.0.1rc4).

4

1 に答える 1

3

このコード テンプレートは次のように使用できます。

public ArrayList<PhongTro> getPhongTros() {
        ArrayList<PhongTro> arrPhongTro = new ArrayList<PhongTro>();

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;

        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);

            /** contains all arrPhongTro objects */
            SoapObject response = (SoapObject) envelope.getResponse();

            /** lists property count */
            final int intPropertyCount = response.getPropertyCount();

            /** loop */
            for (int i = 0; i < intPropertyCount; i++) {
                /** temp SoapObject */
                SoapObject responseChild = (SoapObject) response.getProperty(i);

                /** temp PhongTro object */
                PhongTro tempObj = new PhongTro();

                if (responseChild.hasProperty("att0")) {
                    tempObj.setAtt0(responseChild.getPropertyAsString("att0"));
                }
                if (responseChild.hasProperty("att1")) {
                    tempObj.setAtt1(responseChild.getPropertyAsString("att1"));
                }

                if (responseChild.hasProperty("att2")) {
                    tempObj.setAtt2(responseChild.getPropertyAsString("att2"));
                }

                if (responseChild.hasProperty("att3")) {
                    tempObj.setAtt3(responseChild.getPropertyAsString("att3"));
                }

                if (responseChild.hasProperty("att4")) {
                    tempObj.setAtt4(responseChild.getPropertyAsString("att4"));
                }

                /** Adding temp PhongTro object to list */
                arrPhongTro.add(tempObj);
            }

        } catch (Exception e) {
            e.printStackTrace();

            /** if an error handled arrPhongTro setting null */
            arrPhongTro = null;
        }

        /** returning list */
        return arrPhongTro;
    }
于 2012-05-03T11:30:28.020 に答える