2012-02-21 65 views
0

我爲sharepoint編寫Android客戶端並使用kso​​ap2-android-assembly-2.5.8 lib。我已經下一個代碼:ksoap lib的SOAP信封

public class AndroidWSDLKActivity extends Activity { 
    private static final String NAMESPACE = "http://schemas.microsoft.com/sharepoint/soap/"; 
    private static final String URL = "http://192.168.0.193:30004/SPMobApp/_vti_bin/lists.asmx"; 
    private static final String SOAP_ACTION = "http://schemas.microsoft.com/sharepoint/soap/GetList"; 
    private static final String METHOD_NAME = "GetList"; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     TextView lblResult = (TextView) findViewById(R.id.result); 

     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

        // Set all input params 

     request.addProperty("listName", "Tasks"); 

     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
       // Enable the below property if consuming .Net service 
     envelope.dotNet = true; 
     envelope.setOutputSoapObject(request); 

      HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 

      try 
      { 
       List<HeaderProperty> headerList = new ArrayList<HeaderProperty>(); 
       String authentication = android.util.Base64.encodeToString("LOGIN:PASS".getBytes(), android.util.Base64.NO_WRAP); 

       headerList.add(new HeaderProperty("Authorization", "Basic " + authentication)); 

       androidHttpTransport.call(SOAP_ACTION, envelope); 


       SoapObject response = (SoapObject)envelope.getResponse(); 


       lblResult.setText(response.getProperty(0).toString()); 
      } 
      catch(Exception e) 
      { 
       lblResult.setText(e.getStackTrace().toString()); 
      } 

在此步驟

SoapObject響應=(SoapObject)envelope.getResponse();

在調試模式

我有2個錯誤

語法錯誤,插入 「AssignmentOperator表達」 完成 分配

語法錯誤,插入 「;」完成BlockStatements

什麼錯?幫幫我,PLZ

+0

我想你沒有得到肥皂response.you可以得到響應,JSON字符串 – 2012-02-21 11:40:04

+0

我覺得在一個壞的信封錯誤,但我不知道如何解決它,或者創建сorrect信封 – Gorets 2012-02-21 11:47:35

+0

發表您迴應。 – 2012-02-21 11:55:28

回答

0
public class AndroidWSDLKActivity extends Activity 
{ 
    private static final String NAMESPACE = "http://schemas.microsoft.com/sharepoint/soap/"; 
    private static final String URL = "http://192.168.0.193:30004/SPMobApp/_vti_bin/lists.asmx"; 
    private static final String SOAP_ACTION = "http://schemas.microsoft.com/sharepoint/soap/GetList"; 
    private static final String METHOD_NAME = "GetList"; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 

     TextView lblResult = (TextView) findViewById(R.id.result); 

     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

        // Set all input params 

     request.addProperty("listName", "Tasks"); 

     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
       // Enable the below property if consuming .Net service 
     envelope.dotNet = true; 
     envelope.setOutputSoapObject(request); 

      HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 

      try 
      { 
       List<HeaderProperty> headerList = new ArrayList<HeaderProperty>(); 
       String authentication = android.util.Base64.encodeToString("LOGIN:PASS".getBytes(), android.util.Base64.NO_WRAP); 

       headerList.add(new HeaderProperty("Authorization", "Basic " + authentication)); 

       androidHttpTransport.call(SOAP_ACTION, envelope); 


       SoapObject response = (SoapObject)envelope.getResponse(); 


       lblResult.setText(response.getProperty(0).toString()); 
      } 
      catch(Exception e) 
      { 
       lblResult.setText(e.getStackTrace().toString()); 
      } 
    } 
} 
+0

最新消息? } 到底?對不起,我的錯誤在後,但它沒有幫助我的問題 – Gorets 2012-02-21 11:43:37