這是我的第一篇文章,關於堆棧溢出, 嗯這是我的問題我是一個開墾機器人,我不得不使用KSOAP2從Web服務獲取數據。所以我覺得這個網絡服務: http://www.w3schools.com/xml/tempconvert.asmxksoap2 android打電話,得到null異常
而我試圖得到的結果只有一個TextView電視; 因此,這裏是我的代碼
final static String SOAP_ACTION = "http://www.w3schools.com/xml/CelsiusToFahrenheit";
final static String METHOD = "CelsiusToFahrenheit";
final static String URL = "http://www.w3schools.com/xml/tempconvert.asmx";
final static String NAME_SPACE = "http://www.w3schools.com/xml/";
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fram_rest);
tv = (TextView) findViewById(R.id.myTv);
SoapObject request = new SoapObject(NAME_SPACE, METHOD);
request.addProperty("Celsius", "32");
SoapSerializationEnvelope soapE = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapE.dotNet = true;
soapE.setOutputSoapObject(request);
HttpTransportSE AHT = new HttpTransportSE(URL);
try {
AHT.call(SOAP_ACTION, soapE);
tv.setText("done");
/* SoapPrimitive resultString = (SoapPrimitive) soapSerializationEnvelope.getResponse();
tv.setText("statut: " + resultString.toString());*/
} catch (Exception e) {
String str = e.getMessage();
tv.setText("statut error: " + str);
}
}
我使用的Internet的權限,但我得到的異常呼叫(SOAP_ACTION,...)和「Statut錯誤:空」在我的電視
感謝您的幫助!
P.S:我正在使用android studio 2.0!
看到我的回答如下。 – 2016-05-12 11:37:20