Webサービスの呼び出し中に問題が発生し、サーバーに.NET Webサービスがあり、AndroidでKSOAP(ksoap2-android-assembly-2.5.7-jar-with-dependencies.jar)を使用しています。プログラムの実行中に、「org.ksoap2.serialization.SoapPrimitive」という名前のランタイム例外が発生しました。
リンクで読んだオプションを試してみました:KSOAP2を使用してAndroidから.NET Webサービスを呼び出す方法は?およびkSoap2Android-キャストクラス例外(SoapObject)ですが、何も役に立ちません
これは私のコードです:
try{
//Conexión a Web Service
SoapObject Solicitud = new SoapObject(NAMESPACE, METODO);
PropertyInfo sector = new PropertyInfo();
sector.setName("sector");
sector.setValue(sectorX.toString());
Solicitud.addProperty(sector);
SoapSerializationEnvelope Envoltorio = new SoapSerializationEnvelope (SoapEnvelope.VER12);
Envoltorio.dotNet = true;
Envoltorio.setOutputSoapObject (Solicitud);
HttpTransportSE TransporteHttp = new HttpTransportSE(URL);
TransporteHttp.call (SOAP_ACTION, Envoltorio);
//Obtencion de datos
SoapObject resultado = (SoapObject)Envoltorio.getResponse();
final String[] testValues = new String[resultado.getPropertyCount()];
final Number[] serie = new Number[resultado.getPropertyCount()];
for(int i= 0; i< resultado.getPropertyCount(); i++){
String x = "";
SoapObject wii = (SoapObject)resultado.getProperty(i);
x += wii.getPropertyAsString(1);
testValues[i] = wii.getPropertyAsString(1);
x.trim();
serie[i]=Integer.parseInt(x);
}
ArrayAdapter<String> adaptador = new ArrayAdapter<String>(this, R.layout.lista_sectores, testValues);
final ListView LstOpciones = (ListView) findViewById(R.id.LstOpciones);
LstOpciones.setAdapter(adaptador);
LstOpciones.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View itemClicked,
int position, long id) {
// TODO Auto-generated method stub
TextView textview = (TextView)itemClicked;
String strText = textview.getText().toString();
seleccion.setText("Seleccionado: " + strText);
} catch (Exception e){
txtMensaje.setText(e.getMessage());
}
ここで、sectorXは、WSに指定する文字列パラメーターです。
パラメータなしでWebサービスを試しましたが、機能します。問題は、パラメータを送信するときです...私は推測します:/