ksoap2 lib で .net SOAP Web サービスを使用しようとしています。http://www.vimeo.com/9633556の例は、それを正しく行う方法を示しています。その例のコードの下。すべてがうまくいくはずです!しかし、強制終了エラーが発生します!
ここに私のコード:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class SoapTest2Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView TV ;
TV=(TextView)findViewById(R.id.textView1);
TV.setText("Hi");
String SOAP_ACTION = "http://tempuri.org/CelsiusToFahrenheit";
String METHOD_NAME = "CelsiusToFahrenheit";
String NAMESPACE = "http://tempuri.org/";
String URL = "http://www.w3schools.com/webservices/tempconvert.asmx";
System.setProperty("http.keepAlive", "false");
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
Request.addProperty("Celsius", "32");
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
HttpTransportSE httpTransport = new HttpTransportSE(URL);
try
{
httpTransport.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive resultString = (SoapPrimitive)soapEnvelope.getResponse();
TV.setText(resultString.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
助けてくださいーーーー