Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800
My Carrier: Vodafone

Re: Ksoap parsing

Have you made complex classes implementin KvmSerailizable?

Amar
Trusted Contributor
Posts: 224
Registered: ‎08-09-2011
My Device: 9550
My Carrier: BBprogrammer

Re: Ksoap parsing

[ Edited ]

response = (SoapObject) envelope.getResponse()
In this responce i am getting only 1st college detaiils..
as follows

response.getProperty("email"))
response.getProperty("fullName")

but how i wil get all collegues..

Trusted Contributor
Posts: 224
Registered: ‎08-09-2011
My Device: 9550
My Carrier: BBprogrammer

Re: Ksoap parsing

No
New Developer
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800
My Carrier: Vodafone

Re: Ksoap parsing

Then first make out the complex classes for that.....or i think return is main tag for your response check how many times return comes and den make a loop for it accordingly.

 

 

--------------------------------------------------

--------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!

Amar
Trusted Contributor
Posts: 224
Registered: ‎08-09-2011
My Device: 9550
My Carrier: BBprogrammer

Re: Ksoap parsing

Exactly, but how i wil check how many times that main tag 'return' wil comes..
New Developer
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800
My Carrier: Vodafone

Re: Ksoap parsing

System.out.println("output======" +objects[i].getProperty("return")); or make the subobject of the soap object

 

 

--------------------------------------------------

--------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!

Amar
Trusted Contributor
Posts: 224
Registered: ‎08-09-2011
My Device: 9550
My Carrier: BBprogrammer

Re: Ksoap parsing


objects = new org.ksoap2.serialization.SoapObject[response
.getPropertyCount()];

i am getting null objects array ..

Thats why i am not able to get all data .. how to overcome it.
New Developer
Posts: 120
Registered: ‎05-20-2011
My Device: Touch 9800
My Carrier: Vodafone

Re: Ksoap parsing

You have to make a complex class like this:-

 

package com.emx.forex.complex;

import java.util.Date;
import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;

public class MPortfolio implements KvmSerializable
{
public long id;
public String name;
public String label;
public long customerId;
public String portfolioClass;
public String securityExchange;
public String accountNo;
public String clearingHouseNo;
public Date dateOpened;


public String currency;
public double Amount;
public MPortfolioHolding portfolioHoldings [];

      public MPortfolio()
    {
        
    }
    
    public MPortfolio(long Id,String Name,String Label,long CustomerId,String PortfolioClass,String SecurityExchange,String AccountNo,String ClearingHouseNo,Date DateOpened,
            String Currency,double AmounT,MPortfolioHolding PortfolioHoldings []){
        id=Id;
        name=Name;
        label= Label;
        customerId=CustomerId;
        portfolioClass=PortfolioClass;
        securityExchange=SecurityExchange;
        accountNo=AccountNo;
        clearingHouseNo=ClearingHouseNo;
        dateOpened=DateOpened;
        currency=Currency;
        Amount=AmounT;
        portfolioHoldings=PortfolioHoldings;
        
        
        
        
        
    }
    public Object getProperty(int arg0)
    {
        
        switch (arg0)
        {
        case 0:
            return  new Long (id);
        case 1:
            return name;
        case 2:
            return label;
        case 3:
            return new Long ( customerId);
        case 4:
            return portfolioClass;
        case 5:
            return securityExchange;
        case 6:
            return accountNo;
        case 7:
            return clearingHouseNo;
        case 8:
            return dateOpened;
        case 9:
            return currency;
        case 10:
            return new Double (Amount);
        case 11:
            return portfolioHoldings;
        
        }
        return null;
    }
    

    public int getPropertyCount()
    {
        // TODO Auto-generated method stub
        return 12;
    }

    public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info)
    {
        // TODO Auto-generated method stub
        switch (index)
        {
        case 0:
            info.type = PropertyInfo.LONG_CLASS;
            info.name = "id";
            break;
        case 1:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "name";
            break;
        case 2:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "label";
            break;
        case 3:
            info.type = PropertyInfo.LONG_CLASS;
            info.name = "customerId";
            break;
        case 4:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "portfolioClass";
            break;
        case 5:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "securityExchange";
            break;
        case 6:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "accountNo";
            break;
        case 7:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "clearingHouseNo";
            break;
        case 8:
            info.type = PropertyInfo.OBJECT_CLASS;
            info.name = "dateOpened";
            break;
        case 9:
            info.type = PropertyInfo.STRING_CLASS;
            info.name = "currency";
            break;
        case 10:
            info.type = PropertyInfo.OBJECT_CLASS;
            info.name = "Amount";
            break;
        case 11:
            info.type = PropertyInfo.OBJECT_CLASS;
            info.name = "portfolioHoldings";
            break;
            default:break;
        }
        
    }

    public void setProperty(int index, Object value)
    {
         switch(index)
                {
         case 0:
            id =Long.parseLong(value.toString());
            break;
        case 1:
            name = value.toString();
            break;
        case 2:
            label = value.toString();
            break;
         case 3:
            customerId =Long.parseLong(value.toString());
            break;
        case 4:
            portfolioClass  =  value.toString();
            break;
        case 5:
            securityExchange = value.toString();
            break;
        case 6:
            accountNo = value.toString();
            break;
        case 7:
            clearingHouseNo  =  value.toString();
            break;
        case 8:
            dateOpened  =  (Date) value;
            break;
        case 9:
            currency  =  value.toString();
            break;
        case 10:
            Amount  =  Double.parseDouble(value.toString());
            break;
        case 11:
            portfolioHoldings = (MPortfolioHolding[])value;
            break;    
            default :break;
        
    }
  }
}

 

--------------------------------------------------

--------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!



Amar
Highlighted
Trusted Contributor
Posts: 224
Registered: ‎08-09-2011
My Device: 9550
My Carrier: BBprogrammer

Re: Ksoap parsing

can you explain about     "MPortfolioHolding "  And also  can you explain  how to proceed it...