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
Trusted Contributor
Posts: 123
Registered: ‎09-03-2010
My Device: Blackberry 9000
My Carrier: Airtel

Ksoap issue

hi.. i m very much new to ksoap2 concept.. i want to connect and display the contents from a dot net web service.. can any one help? any reference ?

Highlighted
Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: Ksoap issue

This is the some idead to access a webservice.

 

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
import net.rim.device.api.crypto.certificate.x509.*;
import java.util.Date;
import net.rim.device.api.i18n.SimpleDateFormat;
import net.rim.device.api.i18n.DateFormat;

class SampleScreen extends MainScreen implements FieldChangeListener
{
    ButtonField bf;
    RichTextField txt=new RichTextField();
    public SampleScreen()
    {
        bf=new ButtonField("Click");
        bf.setChangeListener(this);
        add(bf);
    }
    public void webservice()
    {
        add(new RichTextField(":Start Process:"));
        
        String serviceurl = "http://www.deeptraining.com/webservices/weather.a?smx";
        String serviceNamespace = "http://litwinconsulting.com/webservices/";
        String soapAction = "http://litwinconsulting.com/GetWeathe?r";
       
        SoapObject rpc = new SoapObject(serviceNamespace,"GetWeather");
        rpc.addProperty("GetWeather","Canada");
        SoapSerializationEnvelope envlope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
       
        envlope.bodyOut=rpc;
        envlope.dotNet=true;
        envlope.encodingStyle=SoapSerializationEnvelope.XSD;
        rpc.addProperty("Message",(new Date()).toString());
       
        HttpTransport ht = new HttpTransport(serviceurl);
        ht.debug = true;
        String result="";
        try
        {
            ht.call(soapAction, envlope);
            result = (envlope.getResponse()).toString();   
        }catch(Exception e){result=e.toString();}
        //((SampleScreen)this.getActiveScreen()).setScreen?Test(result);       
        add(new RichTextField("==->"+result));        
    }
    public void fieldChanged(Field f,int Context)
    {
        if(f==bf)
        {
            webservice();
        }
    }
}

 

 Not the Actuall code but an Idea.T
Thanks

------------------------------------------------------------------------------------
Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.

Trusted Contributor
Posts: 123
Registered: ‎09-03-2010
My Device: Blackberry 9000
My Carrier: Airtel

Re: Ksoap issue

thanks for replying nitin.. there 3 strings are declared.. one is web service url and i can able to understand tat.. wats the remaining 2 url.. may be my doubt is silly.. but now only i m trying to learn this.. dont mistake..

Developer
Posts: 206
Registered: ‎07-02-2010
My Device: 8320 Curve
My Carrier: Vodacom

Re: Ksoap issue

Hello Dude,

 

Here are some links that will guide you in the right direction:

 

http://www.craigagreen.com/index.php?/Blog/blackberry-and-net-webservice-tutorial-part-1.html

 

http://eightfoldpath.i.ph/blogs/eightfoldpath/2008/12/22/how-to-consume-ksoap2-library-in-blackberry...

 

Hope this will help you. Could you also explain what you are struggling with ?

Trusted Contributor
Posts: 123
Registered: ‎09-03-2010
My Device: Blackberry 9000
My Carrier: Airtel

Re: Ksoap issue

hi. more over, first i tried to create ksoap library application.. i failed in tat also.. when i see to my project properties, i dint find any options like "Blackberry Project Properties"  to assign it as library.. as said in these links..

http://www.blackberryforums.com/developer-forum/200894-using-ksoap2-blackberry-tutorial-one-without-...

-----

http://www.craigagreen.com/index.php?/Blog/blackberry-and-net-webservice-tutorial-part-1.html

-----

i already raised this problem in another thread also..

http://supportforums.blackberry.com/t5/Java-Development/Ksoap-problem/m-p/608858#M126664

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: Ksoap issue

Second url is for  NameSpace of the dotNet webservice.

 

And third url is for the webservice method name.

I think now should be clear.

------------------------------------------------------------------------------------
Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.

Trusted Contributor
Posts: 123
Registered: ‎09-03-2010
My Device: Blackberry 9000
My Carrier: Airtel

Re: Ksoap issue

k nitin.. thanks.. can u please solve my previous issue.. i dint find the "Blackberry Project Properties" to select it as library.. wats the problem here.. 

Developer
Posts: 950
Registered: ‎06-22-2010
My Device: 9550

Re: Ksoap issue

What are you using for Coding JDE or Eclipse.

 

If you are using JDE then I can solve b'coz i am using JDE 5.0;

------------------------------------------------------------------------------------
Press Kudo to say thank to developer.
Also Press the Accept as solution Button when u got the Solution.

Developer
Posts: 206
Registered: ‎07-02-2010
My Device: 8320 Curve
My Carrier: Vodacom

Re: Ksoap issue

Right click on you project,

Click properties

Click Blackberry Project

Click Application Describer

Once that opens then choose library from the "application type" dropdown

 

Alternatively you should have the application Describer in you project's package explorer.

 

Hope this helps

Trusted Contributor
Posts: 123
Registered: ‎09-03-2010
My Device: Blackberry 9000
My Carrier: Airtel

Re: Ksoap issue

yes wesley.. thanks.. ur rite.. it worked now.. but now i m strucked here

"Error starting my_project:module 'ksoap2-j2me-core-prev-2.1.2' not found"Smiley Sad