xml rpcリクエストを作成中に問題が発生しました。 logcat言っlang.ClassCastException whith私seriveのクラッシュ:java.lang.Integerのクライアントコール* >>>テキスト=(文字列)にcoresponds自分のコードの35行では< < < < < *をのClient.call。 (私はすでに知っていたlang.ClassCastException:java.lang.Integer android xml rpc
package tfe.rma.ciss.be;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URI;
import java.util.Enumeration;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;
import android.app.Service;
import android.content.Intent;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.IBinder;
import android.widget.Toast;
public class Addviewer extends Service {
private XMLRPCClient client;
private URI uri;
String text="", IpAdress;
@Override
public void onCreate(){}
public void onStart(Intent intent, int StartId){
uri = URI.create("http://fuseng.elte.rma.ac.be:8080/RPC2");
client = new XMLRPCClient(uri);
getLocalIpAddress();
if (!IpAdress.equals("R.A.S")){
try {
text = (String) client.call("mission.addViewer",IpAdress+ ":" + 8214, "newImage");
} catch (XMLRPCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
text= "erro in adding viewer with the exception:" + e + "/n" + "try again later";
}
Toast.makeText(this,"suscribtion to the viewer with the result " + text, Toast.LENGTH_SHORT).show(); }
else {
Toast.makeText(this,"No network avalaible right now" + "/n" + "try again later", Toast.LENGTH_SHORT).show();
}
}
public String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
IpAdress= inetAddress.getHostAddress().toString();
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
IpAdress="R.A.S";
}
return null;
}
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
}
ので、私は整数(すなわち214)によってsparametr NEWIMAGEを変更し、それ(サービス)は、サーバは、それが二番目のパラメータで文字列を期待していることを私に返信することを除いて正常に動作します...助けてください
Waouhhhhhhhhhhhhhを!これは私の1ヶ月の問題を解決しました。あなたは神があなたを祝福するかもしれない!! – youssoua
@youssoua:ようこそ! – ruakh