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
Regular Contributor
musmankhan90
Posts: 92
Registered: ‎03-09-2013
My Device: bold 9800
My Carrier: blackberry

soap Web services in Blackberry 9800 Bold

Hello Every One,

                         I want to consume my Soap based web service in Blackberry 9800 bold. The url is something like this:

https://abcdefhgk/AndrWSTest/services/PrintMsg?wsdl

 

I didn't get any satisfactory response using google for sample code for consuming Soap Web Service.

Kindly send me any Tutorial link regrading to this or give me any sample code.

 

Thanks in advance.

Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: soap Web services in Blackberry 9800 Bold

Hi

 

the basic steps for developing a Java application that consumes a JSR172 compliant web service (uses Basic Profile only) are as follows:

 

  1. Define the web service and publish its WSDL
  2. Use a tool like the Sun Wireless Toolkit’s Stub Generator to generate the Java code for the web services client
  3. Integrate this code with your BlackBerry application
  4. Job done!

Step (2) generates a "stub". Here are some screen shots of me doing this using the Sun Wireless Toolkit. There are other tools you could use though and I'm sure Google will help you find them.

 

web_service_code_gen.png

 

This will generate source code which you can then copy into your own project.

 

Then all you have to do is invoke the method that corresponds to your web services operation, as implemented in the stub class. In my example I have an operation "getGreeting":

 

	private FieldChangeListener listener = new FieldChangeListener() {
		public void fieldChanged(Field field, int context) {
			WsLab1_Stub web_service = new WsLab1_Stub();
			try {
				String greeting = web_service.getGreeting(name.getText());
				synchronized (UiApplication.getEventLock()) {
					Dialog.inform(greeting);
				}
			} catch (RemoteException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	};

 

Hope this sets you on the right path.

 

Martin

 

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
Developer
simon_hain
Posts: 16,017
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: soap Web services in Blackberry 9800 Bold

while this sample seems functional i would like to add that blocking calls should not be done from the event thread.
the fieldChanged method runs on the event thread, to call the webservice you should use a separate thread.

see http://supportforums.blackberry.com/t5/Java-Development/What-is-the-Event-Thread/ta-p/446865

instead of using stubs you can also use ksoap, searching the forum should result in a lot of hits. depending on your task the ksoap library can be better, but it is more difficult to use initially.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: soap Web services in Blackberry 9800 Bold

...like Simon says :-)

 

Thanks Simon! A while since I've delved into BlackBerry Java :-)

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.