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
Highlighted
New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified
Accepted Solution

Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

Good Day,

 

This is my first post here, I got a lot of information and how-tos very valuable. Thanks.

 

I got a problem, I´m trying to do a proof of concept of consuming .net web services with BlackBerry Java Based App, without using Enterprise Server. I´m a .NET Developer, not much related to java. So be patient Smiley Happy

 

1 First Problem:

 

I have this .NET WebService:

 

 using System.Web.Services;
using System.ComponentModel;

namespace WebServiceTest
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    public class Service1 : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }
}

 

And I´m trying to generate the stub files for using in my project, but I get this:

 

HelloWorld.java :

 

package StubTest2;

public class HelloWorld {
   
    public HelloWorld() {
    }
}

 

 HelloWorldResponse.java  :

 

package StubTest2;

public class HelloWorldResponse {
    protected java.lang.String helloWorldResult;
   
    public HelloWorldResponse() {
    }
   
    public HelloWorldResponse(java.lang.String helloWorldResult) {
        this.helloWorldResult = helloWorldResult;
    }
   
    public java.lang.String getHelloWorldResult() {
        return helloWorldResult;
    }
   
    public void setHelloWorldResult(java.lang.String helloWorldResult) {
        this.helloWorldResult = helloWorldResult;
    }
}

 

Is it correct what the WTK generated? I will or not generate code for consuming, or just the stub, skeleton?

 

2. Second Problem

 

I have the same webservice, but I have a question, how do I use KSOAP in the BlackBerry JDE??  and which imports are needed? Do you have a complete example for this? Thanks in advance!

 

3. Third Problem (Opinion, sugestion)

 

I´m developing a Enterprise App, what JDE do you recomend to use, the BlackBerry JDE or Eclipse wirh the BlackBerry Plug-in?

 

 Thanks in Advance! Smiley Wink

New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

Ohhh, Other Question I forgot!!! Sorry

 

It is  JSR 172 working with BlackBerry 8100 Pearl and Bold? Or I have to use 3rd Party like KSoap?

 

Thanks! Smiley Happy

Developer
Posts: 250
Registered: ‎07-18-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

Hi,

 

JSR-172 support has been added in JDE 4.3.0 so you need a device with OS version > 4.3.0 to use this API. So both Pearl and Bold should work.

New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

PDominique,

 

In fact, I have BBPearl and in the section About, I says V.4.2.0.64 (Platform 2.2.0.37)

 

I´ll chek if I can upgrade it to 4.3

 

Thanks!

 

New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

I have checked, and Mexican Carriers uses 4.2 and there is not upgrade to 4.3 Smiley Sad   **bleep**, I´m stuck, I think will use KSOAP, and I don´t like to use 3rtd Party at all.

 

Any other suggestion?

 

Thanks!

Developer
Posts: 27
Registered: ‎09-04-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

[ Edited ]

If you want to use kSoap you don't need to implement a stubs class like how you would using JSR172.  You can directly use the HTTPTransport object to invoke the webservice.  On the return, you can either use a simple structure like an array to return your data or you can use an XML string, and parse that string on the client end then turn that into whatever you need it to be.  If you want to use kSoap, you will need all their files in your project.  Alternatively, you can build the kSoap code and import as a library into any project you want to use it in.

 

Make sure you don't return any .net constructs like datasets and you should be good to go.

 

One other thing, i find kSoap to be better because you can ensure your code is compatible with more devices. 

Message Edited by mjnip on 10-10-2008 11:44 AM
New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP


mjnip wrote:

If you want to use kSoap you don't need to implement a stubs class like how you would using JSR172.  You can directly use the HTTPTransport object to invoke the webservice.  On the return, you can either use a simple structure like an array to return your data or you can use an XML string, and parse that string on the client end then turn that into whatever you need it to be.  If you want to use kSoap, you will need all their files in your project.  Alternatively, you can build the kSoap code and import as a library into any project you want to use it in.

 

Make sure you don't return any .net constructs like datasets and you should be good to go.

 

One other thing, i find kSoap to be better because you can ensure your code is compatible with more devices. 

Message Edited by mjnip on 10-10-2008 11:44 AM

mjnip,

 

I think cannot update the BB, also removes guarranty from carrier. So my only option is to use KSOAP. And as you say, is compatible with more Java Enabled Devices.

 

Right Now I´m trying with Eclipse and the BBPlug-In, its some complicated (for a .NET Developer), but it is going. Do you know any decent tutorial with eclipse and BB Plug-In? I was trying with the BlackBerry JDE, but it sucks, Eclipse is by far better. Also tryed with VS 2005 plug in, but is very limitated.

 

I´ll have it in mind, just return Native Data Types as Arrays, I think Its all I need.

 

 Thanks !!

Developer
Posts: 250
Registered: ‎07-18-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

Does anyone feel like writing a small tutorial using Ksoap or JSR-172? Smiley Happy

 

A KB article regarding this would be nice...

Developer
Posts: 27
Registered: ‎09-04-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP

I don't use the BB Plugin so don't know of any tutorials.  I use eclipse, import the RIM api library into the project and build using ant tasks.

 

I do my debugging in the BB JDE though cause I've never been able to get that working within eclipse.

New Developer
Posts: 54
Registered: ‎10-07-2008
My Device: Not Specified

Re: Consuming .NET Web Service With BlackBerry JDE 4.6, Java Wireless Toolkit and KSOAP


mjnip wrote:

I don't use the BB Plugin so don't know of any tutorials.  I use eclipse, import the RIM api library into the project and build using ant tasks.

 

I do my debugging in the BB JDE though cause I've never been able to get that working within eclipse.


mjnip,

 

That´s right, right now I´m frustrated with BB Plugin for Eclipse, I was difficult to install, then, I have working that and I have problems importing the net.rim libraries and KSOAP

 

So, do you recommend me using Eclipse Alone (latest version), then use BB JDE for debug?

 

Men, I find it very frustrating, I have almost a week trying to consume my example Web Service.

 

Thanks!