2012-01-15 64 views
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

回答

0

以防萬一:不要忘記將它添加到您的清單。

<uses-permission xmlns:android="http://schemas.android.com/apk/res/android" android:name="android.permission.INTERNET"></uses-permission> 
+0

謝謝你的hanswer,但我已經做到了:) – 2012-01-15 22:32:54