It's not a secret anymore!*
The moose likes Java Micro Edition and the fly likes WSDL consumption Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "WSDL consumption" Watch "WSDL consumption" New topic
Author

WSDL consumption

pranav ganganee
Greenhorn

Joined: Apr 15, 2010
Posts: 5
Hello All,

I want to consume from my mobile a wsdl file (http://localhost:8080/DEMOWS/services/DEMO?wsdl) created in Apache Axis 2 and deployed in my tomcat.

I know there is this KSOAP which does the same but it doesnt support parsing of a WSDL file.
Can anybody help me with any other alternatives?
Alex Parvan
Ranch Hand

Joined: Dec 10, 2009
Posts: 115
Hello,

You can use NetBeans to parse the WSDL, it will create all the classes you need, and you can always call the operations (edit) using the code i wrote in my next post.

While KSOAP can call operations only when you know the parameters and return, the NetBeans generated code reads the WSDL and tells you what parameters you need and how the response looks like, which makes it as easy as calling a normal method.

There is one downside tho, you can only send and recieve Java types (int, double, String, etc.). Using XML complex types is only possible with KSOAP because JAXB is not yet implemented for J2ME.

Hope this helps !
If you have any questions please ask,
Alex.


"Quoting yourself is stupid" - Me
pranav ganganee
Greenhorn

Joined: Apr 15, 2010
Posts: 5
So your first solution via netbeans means i need to first create stubs and wsdl 4 my mobile right??
Alex Parvan
Ranch Hand

Joined: Dec 10, 2009
Posts: 115
The first thing you need to do is to have a WSDL address, like http://localhost:8080/DEMOWS/services/DEMO?wsdl. Then you create a J2ME project in NetBeans. Then you right click on your project and select "New J2ME Web Service Client...", you enter the WSDL address and you are finished. The WSDL will be imported automatically by NB and all the code will be generated.

Once you've done this, you can use any WS operation at any time in your code. I was wrong in my first post, right click -> insert code can only be done in J2SE, in J2ME you use this code:

Once you write "service." NetBeans will show you all the operations with their parameters and what they return, just like a normal method.

Alex.
pranav ganganee
Greenhorn

Joined: Apr 15, 2010
Posts: 5
Thanks a ton Alex. I did the same thing. But what i want to do is...i want to reduce my j2me application size by not including wsdl and stubs and other return type specific classes. So what i want to know is "Does KSOAP come to the rescue in here? Will it not create stubs and wsdl on mobile device? "
In brief when can i use KSOAP? I hope i am not irritating you by answering too many questions.
Alex Parvan
Ranch Hand

Joined: Dec 10, 2009
Posts: 115
Don't worry about asking too many questions, i know how it is when no one helps you So just ask freely, if i can, i will help.

So, kSOAP does not create any classes, kSOAP calls the WS address you give it, you write the parameters manually. So basicly kSOAP is the manual way to call a WS operation.

The ksoap2 library contains the following classes:
org.ksoap2.SoapEnvelope;
org.ksoap2.serialization.SoapObject;
org.ksoap2.serialization.SoapSerializationEnvelope;
org.ksoap2.transport.HttpTransport;
which are used to call a WS operation.

Then you must read the SOAP response again manually.

Say you want to call an operation that looks like this:
public boolean login(String username, String password)
Here is the complete code how to call a WS operation using kSOAP:

Maybe seeing the code gives you an ideea how kSOAP works, you can just put this code in your J2ME application and use it, nothing else is needed. No stubs / classes will be generated.

Unfortunately these are the only 2 ways i know how to call a WS operation, and i find using kSOAP more efficient, althought it's slightly more complex.

Feel free to ask if you have any more questions or don't understand something,
Alex.
pranav ganganee
Greenhorn

Joined: Apr 15, 2010
Posts: 5
Bigno!!! You hit the target Alex. Thnx again. This was what i needed.
Alex Parvan
Ranch Hand

Joined: Dec 10, 2009
Posts: 115
Glad i could help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WSDL consumption
 
Similar Threads
Webservices exposed on web
First JAX-WS webservice results in UnsupportedMediaException
Deploying the webservice
webservices with jboss
Web service to validate US states, city and zipcode