我正在尝试将 .net SOAP Web 服务与 ksoap2 lib 一起使用。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();
}
}
}
请帮助 meeeeee