我尝试在 Android 中显示一个值,该值是通过肥皂调用检索的。但我不能让它工作。如果我运行我的应用程序,计数值会显示在我的 tomcat-apache 上。但是计数值没有显示在我的安卓模拟器上。为什么这里没有显示计数值。请帮我。我知道原因。但我无法弄清楚代码部分。我的错误是我的 android 代码部分。我可以在哪里更改我的代码。
这是我的网络服务代码:
public class RetailerWs {
public String customerData(){
String customerInfo = "";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/xcart-432pro","root","");
//Find customer information where the customer ID is maximum
PreparedStatement statement = con.prepareStatement("select * from xcart_orders where status='Q' AND date = CURDATE()");
ResultSet result = statement.executeQuery();
int count=0;
while(result.next()){
count++;
System.out.println(count);
}
}
catch(Exception exc){
System.out.println(exc.getMessage());
}
return customerInfo;
}
}
这是我的 android 代码部分:
public class RetailerActivity extends Activity {
private static final String SOAP_ACTION = "http://xcart.com/customerData";
private static final String METHOD_NAME = "customerData";
private static final String NAMESPACE = "http://xcart.com";
private static final String URL = "http://192.168.1.168:8085/XcartLogin/services/RetailerWs?wsdl";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.retrieve);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(URL);
try {
ht.call(SOAP_ACTION, envelope);
SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
SoapPrimitive s = response;
String str = s.toString();
String resultArr[] = str.split("&");//Result string will split & store in an array
TextView tv = new TextView(this);
for(int i = 0; i<resultArr.length;i++){
tv.append(resultArr[i]+"\n\n");
}
setContentView(tv);
} catch (Exception e) {
e.printStackTrace();
}
}
}
我应该在哪里更改我的 android 代码以在 android 模拟器上打印计数值。