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

Native Development

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Contributor
Posts: 8
Registered: ‎02-12-2013
My Device: all
My Carrier: ..

connecting to server glassfish (webservice)


Can u please help me,

i am trying to connect to webservice from my application but i couldn't establich the connection Smiley Sad please can someone help me where is the problem or give me a code to restart the connection.

the code that i used is:

package com.KsoapConnectionTest;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;
import org.xmlpull.v1.XmlPullParserException;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.MainScreen;

public class testMainScreen extends MainScreen {
private RichTextField textField;
private ButtonField srvButton = new ButtonField("Service Call");

public testMainScreen() {
System.out.println("Adding text");
LabelField title = new LabelField("HelloWorld Sample",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
textField = new RichTextField("Hello World!");
System.out.println("Added text");


FieldChangeListener listenerSrvButton = new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
String serviceUrl = "http:/xxxxxxxxxxxx?wsdl";
String serviceNamespace = "http://WS/";
String soapAction = "http://WS/getActiveStates";
String serviceMethod = "getActiveStates";//getAboutUsContent


HttpTransport ht = new HttpTransport(serviceUrl);

ht.debug = true;
ht.setXmlVersionTag(" version=\"1.0\" encoding=\"UTF-8\"?>");

SoapObject rpc = new SoapObject(serviceNamespace, serviceMethod);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

// envelope.setOutputSoapObject(rpc);

System.out.println("Created envelope");
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
* envelope.encodingStyle = SoapSerializationEnvelope.ENC;
* envelope.encodingStyle = SoapSerializationEnvelope.XSI;

// rpc.addProperty("Celsius", "12");
String result = "";
try {

ht.call(soapAction, envelope);
result = (envelope.getResponse()).toString();
System.out.println(result);// for debugging

} catch (XmlPullParserException ex) {
String msg = ex.toString();
} catch (Exception ex) {
System.out.println("i am here in catch");
// String msg = ex.toString();

// ((HelloWorldScreen)this.getActiveScreen()).setScre enTest(result);
* public void setScreenTest(String text) { textField.setText(text); }

public boolean onClose() {
return true;



The problem is when the debug inter the call zone so please can someone tell me how to connect ? or give me another methos? thank you so much