0
大家好我在做一個應用程序,我需要從Web服務的一些信息,我寫了這個代碼:SOAPACTION和Web服務不工作
package messinaline.matteo.app;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MessinaAppActivity extends Activity {
private static final String SOAP_ACTION = "FINDPORT";
private static final String METHOD_NAME = "FINDPORTRequest";
private static final String NAMESPACE = "urn:DefaultNamespace";
private static final String URL = "http://apps.messinaline.it:80/TestWSDL.nsf/CheckNaveNew?OpenWebService";
private Object resultRequestSOAP = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(R.id.webservice);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// SoapObject
request.addProperty("SHIP", "Jolly Blu");
request.addProperty("XDATE", "15/01/2012");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
String[] resultsRequestSOAP = (String[]) envelope.getResponse();
tv.setText(resultsRequestSOAP[0]);
} catch (Exception aE) {
aE.printStackTrace();
tv.setText("don't work");
}
}
}
我發現這裏的代碼http://www.anddev.org/calling_a_web_service_from_android-t348.html TextView的告訴我「不工作」?爲什麼?謝謝sooo
謝謝你的hanswer,但我已經做到了:) – 2012-01-15 22:32:54