我使用了下面的代码
public class SharepointListActivity extends Activity {
private static final String SOAP_ACTION = "http://schemas.microsoft.com/sharepoint/soap/Login";
private static final String METHOD_NAME = "Login";
private static final String NAMESPACE = "http://schemas.microsoft.com/sharepoint/soap/" ;
private static final String URL = "http://192.168.0.25:1000/_vti_bin/authentication.asmx";
private TextView result;
private Button btnSubmit;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
result = (TextView)findViewById(R.id.editText1);
btnSubmit = (Button)findViewById(R.id.button1);
btnSubmit.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
if(v.getId() == R.id.button1)
{
String list = getMobileTestList();
result.setText(list);
}
}
});
}
private String getMobileTestList()
{
PropertyInfo pi = new PropertyInfo();
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE transport = new HttpTransportSE(URL);
try
{
transport.debug = true;
transport.call(SOAP_ACTION, envelope);
Object result = envelope.getResponse();
return result.toString();
}
catch(Exception e)
{
return e.toString();
}
}
}
作为回应,我有这样的 xml
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<LoginResult>
<CookieName>FedAuth</CookieName>
<ErrorCode>NoError</ErrorCode>
<TimeoutSeconds>1800</TimeoutSeconds>
</LoginResult>
</LoginResponse>
</soap:Body>
</soap:Envelope>
接下来我应该做什么,这样我就可以从 GetList 方法中获取答案。我应该如何进行身份验证?
如果我更改 GetList 方法的 METHOD_NAME、SOAP_ACTION 和其他参数,我会遇到错误 - 403 被禁止。导致错误的身份验证,那么我应该如何构建正确的查询?或者我应该如何处理下一个查询的第一个答案?