2 Replies Latest reply on Mar 4, 2008 4:26 PM by 807591

    java.io: open tunnel failure

    807591
      Hi all - i'm trying to use ksoap2 to access a webservice from a blackberry but the request fails with the following error

      java.io: open tunnel failure

      anybody know whats happening here? and how to solve it?

      any help is much appreciated

      the bolded line is the where the request fails

      thanks in advance
      Alex
      /*
       * ConnectionThread.java
       *
       * &copy; <your company here>, 2003-2005
       * Confidential and proprietary.
      */*
      
      *import org.ksoap2.*;
      import org.ksoap2.serialization.*;*
      *import org.ksoap2.transport.*;
      
      import net.rim.device.api.system.*;*
      *import java.util.*;
      import java.io.*;*
      *//import net.rim.device.api.xml.parsers.*;
      
      
      //import java.util.Timer;
      //import java.util.TimerTask;
      
      
      /**
       * 
       */
      class ConnectionThread extends Thread{
          private boolean start = false;
      
          private boolean stop = false;
      
          private String url,lon,lat,prop1,prop2,method;
      
          private String data;
      
          public String error="";
      
          public boolean sendResult = false;
      
          public boolean sending = false;
      
          //private String requestMode = HttpConnection.POST;
      
          public String responseContent;
      
          public void run() {
              while (true) {
                  if (start == false && stop == false) {
                      try {
                          sleep(200);
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
                  } else if (stop) {
                      return;
                  } else if (start) {
                      doSoap();
                  }
              }
          }
      
          //ConnectionThread() {    }
      
      
          public void doSoap(){
      
              //code to connect to web service
              HttpTransport transport=null;
              System.err.println("2"+ url);
                      try{
                  //create soap object
                  SoapObject SO = new SoapObject("http://www.rim.net/","GetClientData");
                  //add properties
                  SO.addProperty("Lat","40.976745664");
                   SO.addProperty("Lon","-71.743456");
                   SO.addProperty("Radius","35");
                   SO.addProperty("Pin","252139B3");
      
      
                  //create soap envelope
                  SoapSerializationEnvelope en = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                  //add soapobject to envelope
                  System.err.println("3");
                  en.setOutputSoapObject(SO);
                  en.dotNet = true;
                  en.encodingStyle = SoapSerializationEnvelope.ENC;
                  System.err.println("4" + en.toString());
      
                  //create transport to server    
                  //transport = new HttpTransport(_resources.getString(SERVER_URL));
                  transport = new HttpTransport(url);
                  transport.debug = true;
                  System.err.println("5");
                  //use the transport to call a web service method and pass in the enveople
                  *transport.call("GetClientData", en);*   //format to call web service - uurn:PriceService#getPrice
                  System.err.println("6");
      
                  //dialog.alert(en.toString());
                 // Dialog.alert("Are you sure?");
                 if(transport.responseDump!=null)
                  sendResult = true;
      
                  start = false;
                  sending = false;
              }
      
              catch(Exception e){
                  System.err.println("7" + e.toString());
                  System.err.println( transport.requestDump );
                 // Dialog.alert(transport.requestDump);
                  System.err.println( transport.responseDump );
                  start = false;
                  sendResult = false;
                  sending = false;
      
              }
          }
      
      
          public void get(String url,String method,String lon,String lat,String prop1,String prop2) {
              this.url = url;
              this.method = method;
              this.lon = lon;
              this.lat = lat;
              this.prop1 = prop1;
              this.prop2 = prop2;
              this.data = "";
              sendResult = false;
              sending = true;
              start = true;
          }
      
          public void stop() {
              stop = true;
          }
      
      
      } 
      Edited by: brasil181 on Mar 4, 2008 8:06 AM