• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

WSDL consumption

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
pranav ganganee
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So your first solution via netbeans means i need to first create stubs and wsdl 4 my mobile right??
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bigno!!! You hit the target Alex. Thnx again. This was what i needed.
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad i could help
 
reply
    Bookmark Topic Watch Topic
  • New Topic