我看一下以下是SP服务器的SOAP 1.1请求示例,但是没关系。
POST /_vti_bin/lists.asmx HTTP/1.1
Host: 192.168.0.25
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetList"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>string</listName>
</GetList>
</soap:Body>
</soap:Envelope>
字段 Content-Length:length 需要替换为实际值。它的价值是什么?我在哪里可以看到它?或者如何在请求之前计算它的值?
UPD1。 我用ksoap lib
headerPropertyObj = new HeaderProperty("Content-Length", "383"); // should be calc before
headerList.add(headerPropertyObj);
transport.setUrl(URL);
request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("listName", "Tasks");
envelope.setOutputSoapObject(request);
transport.call(SOAP_ACTION, envelope, headerList);
答案 0 :(得分:3)
我解决了这个问题。我自己写了课
public class MyHttpTransportSE extends Transport
我在哪里重新加载下面的呼叫方法
public List call(String soapAction, SoapSerializationEnvelope envelope, List headers)
throws IOException, XmlPullParserException {
if (soapAction == null)
soapAction = "\"\"";
byte[] requestData = createRequestData(envelope);
requestDump = debug ? new String(requestData) : null;
responseDump = null;
connection = getServiceConnection();
connection.setRequestProperty("User-Agent", "kSOAP/2.0");
// connection.setRequestProperty("SOAPAction", soapAction);
// connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestProperty("Content-Type", "application/soap+xml");
connection.setRequestProperty("Connection", "close");
connection.setRequestProperty("Content-Length", "" + requestData.length);
它对我有帮助,我希望这对smb有帮助。
答案 1 :(得分:1)
Content-Length
值是正文的长度(以字节为单位),以第一个<
开头,以正文的最后一个字符结尾,此处>
或者可能是换行符。
答案 2 :(得分:0)
以正确的方式创建信封应该足够了,而不需要自己设置标题。
http://www.helloandroid.com/tutorials/using-ksoap2-android-and-parsing-output-data
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
httpTransport.debug = true; //try debugging
如果您的问题与sharepoint身份验证有关,那么您应该正确添加信封标头,以便长度不断由库本身计算。 Error in authentication when subscribing to a sharepoint webservice using ksoap2-android
这有助于:http://davidsit.wordpress.com/2010/03/03/creating-sharepoint-list-items-with-php/