0
我正在使用KSOAP2库调用ASP.NET Web服务。我没有得到任何错误,但我也没有得到任何答案任何想法来解决这个问题。KSOAP2不返回任何结果
以下是我的代码。我只是简单地调用返回字符串的helloworld默认方法。
public class MainActivity extends Activity {
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://(ip)/TrialService.asmx";
private final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private final String METHOD_NAME = "HelloWorld";
TextView t1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t1 = (TextView) findViewById(R.id.textView1);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
if (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
}
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
String receivedInt = (String) envelope.getResponse();
t1.setText(receivedInt);
setContentView(t1);
} catch (Exception e) {
t1.setText("error");
}
}
}