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: 17
Registered: ‎07-16-2012
My Device: None
My Carrier: None

Ksoap Connect to Webservice

Hi All,

 

I'm very new to Blackberry and Java, while I'm trying to connect to a simple .NET web service but it takes a long time to load and outputs nothing to the screen.

 

So from the following code, what could i being doing wrong?

 

public static String callCelsiusToFahrenheit(String celcius) throws Exception
{

         String server_url = "http://www.w3schools.com/webservices/tempconvert.asmx";
         String soap_namespace = "http://tempuri.org/";
        
         String soap_action;
         String method = "CelsiusToFahrenheit";
         String result = "";
       
         soap_action = soap_namespace + method;
                
          // Build request
         SoapObject request = new SoapObject(soap_namespace, method);
         request.addProperty("Celsius", celcius);// variables that will be set
          
         // Build envelope
         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
         envelope.dotNet = true;
         envelope.setOutputSoapObject(request);
          
         // Set http transport
         HttpTransport ht = new HttpTransport(server_url);
         ht.debug = true;
        
          try
          {
             ht.call(soap_action, envelope);
             SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
             result = ""+response;
          }
          catch (Exception e)
          {
              //print out error
             e.printStackTrace();
          }
          return result;

}