安卓设备不工作

问题描述:

我已经开发了一个使用soap webservices.it的计算示例scuuessfully在我的模拟器上工作,但它不工作在我的android真实设备上。为什么dis没有在我的设备上工作。安卓设备不工作

DIS是我的代码:

package org.web.frontend.calculator; 
import java.io.IOException; 
import java.net.SocketException; 

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

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.TextView; 
import android.util.Log; 
public class AndroidWSDLFrontEnd extends Activity { 

private String METHOD_NAME ="sum"; 
private String NAMESPACE = "http://calculator.backend.web.org"; 
private String SOAP_ACTION = NAMESPACE + METHOD_NAME; // NAMESPACE + method name 
private static final String URL = "http://192.168.1.168:8085/Calculation/services /Calculate?wsdl"; // you must use ipaddress here, don’t use Hostname or localhost 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.main); 
TextView tv = (TextView) findViewById(R.id.txtAddition); 


try 
{ 
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
request.addProperty("i", 15); 
request.addProperty("j", 10); 

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
envelope.dotNet = true; 
envelope.setOutputSoapObject(request); 
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
androidHttpTransport.call(SOAP_ACTION,envelope); 
Object result = envelope.getResponse(); 
System.out.println("Result : " + result.toString()); 
((TextView) findViewById (R.id.txtAddition)).setText("Addition : "+result.toString()); 
} catch (SocketException E) { 
E.printStackTrace(); 
((TextView) findViewById (R.id.txtAddition)).setText("ERROR: " + E.getClass().getName() + ":" + E.getMessage()); 
    } 
catch (IOException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
    } catch (XmlPullParserException e) { 
// TODO Auto-generated catch block 
e.printStackTrace(); 
    } 
    } 
    } 

请帮助我。

+0

解释“为什么DIS没有奏效”,何况错误 – 2012-07-28 04:26:59

+0

当我运行我的应用程序显示在我的真实device.java.net.SocketException错误以下。操作超时错误显示在我的设备上。 – hariprasad 2012-07-28 04:32:43

+0

套接字异常通常与TCP错误有关,将您的设备与PC连接并粘贴Logcat,以便更好地理解您的问题。 – 2012-07-28 04:43:57

您的声音与http://192.168.1.168:8085/Calculation/services/Calculate?wsdl%22不在同一网络中。你在移动网络上吗?如果是这样,请连接到Wi-Fi并尝试。另外,如果需要,您可能必须为您的网络配置代理或VPN以允许访问。

检查您的移动IP地址,并与您当前给出ipadrees更换

private static final String URL = "http://192.168.1.168:8085/Calculation/services /Calculate?wsdl"; 

请检查您的网络连接至极使用