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: 30
Registered: ‎09-20-2012
My Device: BlackBerry Curve 8330
My Carrier: vodafone

Re: getting error while using KSoap Parsing.

Hi Pankaj,

    I replaced the method name in both places i.e., GetConsumerLoginValidate. even though the app is crashing at the same line only...

 

public boolean loginPArse(String username, String password) {

boolean ans = false;
String result = null;
SoapObject request = new SoapObject("http://tempuri.org/","GetConsumerLoginValidate");
request.addProperty("username",username);
request.addProperty("password",password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet = true;
HttpTransport ht = new HttpTransport("safsafsafasfasfafafas.asmx");
ht.debug = true;
try {
ht.call("http://tempuri.org/GetConsumerLoginValidate", envelope);
SoapObject body = (SoapObject) envelope.bodyIn;
result = (String) body.getProperty("NewDataSet").toString();
System.out.println("Result is: " + result);
}
catch (XmlPullParserException ex) {
//Dialog.alert("ex1 "+ex.toString() );
ex.printStackTrace();
} catch (IOException ex) {
//Dialog.alert("ex2 " +ex.toString());
ex.printStackTrace();
} catch (Exception ex) {
//Dialog.alert("ex3 " + ex.toString());
ex.printStackTrace();
}
return ans;
}

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

Hi

How is your internet connection is working.

My means

String s = "http://tempuri.org/GetConsumerLoginValidate"+ConnectionInfo.getInstance().getConnectionParameters();

Thanks
New Developer
Posts: 30
Registered: ‎09-20-2012
My Device: BlackBerry Curve 8330
My Carrier: vodafone

Re: getting error while using KSoap Parsing.

Hi Pankaj,

      I am getting error at getInstance() method.

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

Hi here you need to say the internet way of connection.

Thanks
Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

Hi,

 

If you don't have any class to connection. then use this class.

 

import net.rim.device.api.servicebook.ServiceBook;
import net.rim.device.api.servicebook.ServiceRecord;
import net.rim.device.api.system.CoverageInfo;
import net.rim.device.api.system.WLANInfo;

public class ConnectionInfo
{

    private String connectionParameters = "";
    private static ConnectionInfo instance;
    public ConnectionInfo()
    {
        instance = this;
        
   	 if (WLANInfo.getWLANState() == WLANInfo.WLAN_STATE_CONNECTED)
        {
              // Connected to a WiFi access point
            connectionParameters = ";interface=wifi";
        } 
        else 
        {
            int coverageStatus = CoverageInfo.getCoverageStatus();
            ServiceRecord record = getWAP2ServiceRecord();
            if (record != null && (coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) 
            {
                // Have network coverage and a WAP 2.0 service book record
                connectionParameters = ";deviceside=true;ConnectionUID="+ record.getUid();
            } 
            else if ((coverageStatus & CoverageInfo.COVERAGE_MDS) == CoverageInfo.COVERAGE_MDS) 
            {
            // Have an MDS service book and network coverage
                connectionParameters = ";deviceside=false";
            } 
            else if ((coverageStatus & CoverageInfo.COVERAGE_DIRECT) == CoverageInfo.COVERAGE_DIRECT) 
            {
                // Have network coverage but no WAP 2.0 service book record
                connectionParameters = ";deviceside=true";
            }
        }
    }
    
    public static ConnectionInfo getInstance()
    {
        if(instance == null)
        {
            instance = new ConnectionInfo();
        }
        
        return instance;
    }
    private ServiceRecord getWAP2ServiceRecord() 
    {
        ServiceBook sb = ServiceBook.getSB();
        ServiceRecord[] records = sb.getRecords();
        for(int i = 0; i < records.length; i++) 
        {
            String cid = records[i].getCid().toLowerCase();
            String uid = records[i].getUid().toLowerCase();
            if (cid.indexOf("wptcp") != -1 && uid.indexOf("wifi") == -1 && uid.indexOf("mms") == -1) 
                return records[i];
        }
        return null;
    }
    
    public String getConnectionParameters()
    {
        return connectionParameters;
    }


}

 

Thanks

Pawan

New Developer
Posts: 30
Registered: ‎09-20-2012
My Device: BlackBerry Curve 8330
My Carrier: vodafone

Re: getting error while using KSoap Parsing.

Hi.

 I am getting this message

"http://tempuri.org/GetConsumerLoginValidate;deviceside=true;ConnectionUID=S TCP-T[90.734] "

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

Hi

I don't know why u r facing this issue

Can you share your entire detail?
Thanks
New Developer
Posts: 30
Registered: ‎09-20-2012
My Device: BlackBerry Curve 8330
My Carrier: vodafone

Re: getting error while using KSoap Parsing.

If i forward my code 2 u means then the serviceURL wont work because its our local machine. Anyway i am sharing my code 2 u...

 

Developer
Posts: 209
Registered: ‎04-30-2011
My Device: BlackBerry Z10
My Carrier: Airtel

Re: getting error while using KSoap Parsing.

HI

 

Use this

 

public boolean loginPArse(String username, String password) {

boolean ans = false;
String result = null;
SoapObject request = new SoapObject("http://tempuri.org/","GetConsumerLoginValidate");
request.addProperty("username",username);
request.addProperty("password",password);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet = true;
HttpTransport ht = new HttpTransport("<your project url>.asmx"+"ConnectionInfo.getInstance().getConnectionParameters());
ht.debug = true;

System.out.println("connectionType is: " + connectionType);
try {
ht.call("http://tempuri.org/GetConsumerLoginValidate", envelope);
SoapObject body = (SoapObject) envelope.bodyIn;
result = (String) body.getProperty("NewDataSet").toString();
System.out.println("Result is: " + result);
}
catch (XmlPullParserException ex) {
//Dialog.alert("ex1 "+ex.toString() );
ex.printStackTrace();
} catch (IOException ex) {
//Dialog.alert("ex2 " +ex.toString());
ex.printStackTrace();
} catch (Exception ex) {
//Dialog.alert("ex3 " + ex.toString());
ex.printStackTrace();
}
return ans;
}

 

This will work fine. here was one mistake. that i did remove.

 

Thanks