ksoap库的SOAP信封

时间:2012-02-21 11:11:13

标签: java android sharepoint soap

我为sharepoint编写android客户端并使用kso​​ap2-android-assembly-2.5.8 lib。我接下来是代码:

 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 response =(SoapObject)envelope.getResponse();

在调试模式下我有2个错误

  

语法错误,插入“AssignmentOperator Expression”完成   作业

     

语法错误,插入“;”完成BlockStatements

什么错了?帮帮我,PLZ

1 个答案:

答案 0 :(得分: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());
             }
    }
}