引数として文字列を取る SOAP サービスがあり、andrid コードからそれを呼び出します。私のコード例では、それを行うために AsyncTask を使用しています。doInBackground メソッドで、2 つのサービスを呼び出します。最初のサービスはデータを取得し (引数なし)、2 つ目は文字列を引数として取り、void を返します。
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Vector<SoapObject> result = (Vector<SoapObject>) envelope
.getResponse();
request = new SoapObject(NAMESPACE, METHOD_NAME2);
PropertyInfo property=new PropertyInfo();
property.setName("lastDate");
property.setValue("2013/09/10 14:51:08");
property.setValue(java.lang.String.class);
request.addProperty(property);
envelope.setOutputSoapObject(request);
androidHttpTransport.call(SOAP_ACTION, envelope);
しかし、2 番目のサービス (METHOD_NAME2) を呼び出そうとすると、次のエラーが発生します。
09-24 18:21:49.096: E/AndroidRuntime(23906): FATAL EXCEPTION: AsyncTask #1
09-24 18:21:49.096: E/AndroidRuntime(23906): java.lang.RuntimeException: An error occured while executing doInBackground()
09-24 18:21:49.096: E/AndroidRuntime(23906): at android.os.AsyncTask$3.done(AsyncTask.java:299)
09-24 18:21:49.096: E/AndroidRuntime(23906): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
09-24 18:21:49.096: E/AndroidRuntime(23906): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
09-24 18:21:49.096: E/AndroidRuntime(23906): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
09-24 18:21:49.096: E/AndroidRuntime(23906): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
09-24 18:21:49.096: E/AndroidRuntime(23906): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
09-24 18:21:49.096: E/AndroidRuntime(23906): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
09-24 18:21:49.096: E/AndroidRuntime(23906): at java.lang.Thread.run(Thread.java:841)
09-24 18:21:49.096: E/AndroidRuntime(23906): Caused by: java.lang.RuntimeException: Cannot serialize: class java.lang.String
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:664)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:649)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:595)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:573)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:658)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:555)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:205)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.transport.Transport.createRequestData(Transport.java:134)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:144)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)
09-24 18:21:49.096: E/AndroidRuntime(23906): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111)
09-24 18:21:49.096: E/AndroidRuntime(23906): at com.example.soapclient.DownloadDataTask.doInBackground(DownloadDataTask.java:60)
09-24 18:21:49.096: E/AndroidRuntime(23906): at com.example.soapclient.DownloadDataTask.doInBackground(DownloadDataTask.java:1)
09-24 18:21:49.096: E/AndroidRuntime(23906): at android.os.AsyncTask$2.call(AsyncTask.java:287)
09-24 18:21:49.096: E/AndroidRuntime(23906): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
09-24 18:21:49.096: E/AndroidRuntime(23906): ... 4 more
どうしたの?