我尝试使用ksoap2 lib构建正确的肥皂信封
...
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("listName", "Tasks");
request.addProperty("viewName", null);
request.addProperty("query", null);
request.addProperty("viewFields", null);
request.addProperty("rowLimit", "30");
request.addProperty("queryOptions", null);
request.addProperty("webID",null);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
String authentication = android.util.Base64.encodeToString("Administrator:Password".getBytes(), android.util.Base64.NO_WRAP);
List<HeaderProperty> headers = new ArrayList<HeaderProperty>();
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
androidHttpTransport.debug = true;
try {
headers.add(new HeaderProperty("Authorization", "Basic " + authentication));
androidHttpTransport.call(SOAP_ACTION, envelope, headers);
Log.d("D", androidHttpTransport.requestDump);
SoapObject response = (SoapObject) envelope.getResponse();
...
在调试模式下,我看到这个信封:
<?xml version="1.0" encoding="utf-8"?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header/>
<v:Body>
<GetListItems id="o0" c:root="1" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName i:type="d:string">Tasks</listName>
<viewName i:null="true"/>
<query i:null="true"/>
<viewFields i:null="true"/>
<rowLimit i:type="d:string">30</rowLimit>
<queryOptions i:null="true"/>
<webID i:null="true"/>
</GetListItems>
</v:Body>
</v:Envelope>
标题数据在哪里?也许它会被添加到调用方法中? 它是一个正确的信封? 我在上一篇文章中也有同样的错误,在服务器上有授权。
答案 0 :(得分:0)
标头数据是在HTTP标头中发送的,而不是在SOAP主体中发送,这就是它们称之为标头的原因。使用“HTTP基本”身份验证时,会添加Authorization
标头。请参阅维基百科的示例:http://en.wikipedia.org/wiki/Basic_access_authentication#Example