KSOAP2 で整数の配列を受け取る際に問題があります。http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricksのチュートリアルに従い、次のクラスを作成しました。
package pl.webcentral.reversi;
import java.util.Hashtable;
import java.util.Vector;
import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
public class Fields extends Vector<String> implements KvmSerializable {
/**
*
*/
private static final long serialVersionUID = -1166006770093411055L;
@Override
public Object getProperty(int arg0) {
return this.get(arg0);
}
@Override
public int getPropertyCount() {
return this.size();
}
@Override
public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
arg2.name = "string";
arg2.type = PropertyInfo.STRING_CLASS;
}
@Override
public void setProperty(int arg0, Object arg1) {
this.add(arg1.toString());
}
}
配列の送信:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
PropertyInfo propInfo=new PropertyInfo();
propInfo.setName("arg0");
propInfo.setType(PropertyInfo.STRING_CLASS);
propInfo.setValue(sessionId);
request.addProperty(propInfo);
// Sending the array representing our board:
Fields fieldsVector = new Fields();
for (int i=0; i<65; i++) {
fieldsVector.add(move[i].toString());
}
PropertyInfo fieldsPropertyInfo = new PropertyInfo();
fieldsPropertyInfo.setName("fields");
fieldsPropertyInfo.setValue(fieldsVector);
fieldsPropertyInfo.setType(fieldsVector.getClass());
request.addProperty(fieldsPropertyInfo);
PropertyInfo sessionPropertyInfo = new PropertyInfo();
sessionPropertyInfo.setName("arg0");
sessionPropertyInfo.setType(PropertyInfo.STRING_CLASS);
sessionPropertyInfo.setValue(sessionId);
request.addProperty(sessionPropertyInfo);
envelope.setOutputSoapObject(request);
envelope.addMapping(NAMESPACE, "fields", new Fields().getClass());
HttpTransportSE androidHttpTransport = new HttpTransportSE(WSDL_URL);
// androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
try {
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
} catch (SoapFault e) {
System.out.println("Error adding move: " + e.faultstring);//można to ładnie jakoś pokazać na ekranie
throw e;
}
}
XMLが実際にどのように見えるかはわかりません。このデバッグを設定しようとしましたが、方法がわかりません。したがって、これをすべて取得する方法がわかりません...