3

I look at the following is a sample SOAP 1.1 request to SP server, but its does not matter.

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>

The field Content-Length: length need to be replaced with actual values. What its value? Where is I can see it? Or how to calculate it value before request?

UPD1. I use 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);
Gorets
  • 2,434
  • 5
  • 27
  • 45

3 Answers3

3

I solved this problem. I wrote myself class

public class MyHttpTransportSE extends Transport

where is I reloaded call method like below

     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);

Its helped for me, I hope this helps for smb.

Gorets
  • 2,434
  • 5
  • 27
  • 45
1

The Content-Length value is the length (in bytes) of the body, which starts with the first < and ends with the last character of the body, here > or maybe a newline.

Florent Guillaume
  • 8,243
  • 1
  • 24
  • 25
0

Creating the envelope the right way should be enough, without setting headers by yourself.

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

If your problem relates to sharepoint authentication, then you should add envelope headers properly so the length keeps being calculated by the library itself. Error in authentication when subscribing to a sharepoint webservice using ksoap2-android

this could help: http://davidsit.wordpress.com/2010/03/03/creating-sharepoint-list-items-with-php/

Community
  • 1
  • 1
Alfabravo
  • 7,493
  • 6
  • 46
  • 82
  • In my envelope header I must add a token from previous query. Token its a cookies with auth data to sharepoint server, without their I cant have other data. – Gorets Feb 29 '12 at 07:27
  • I solved problem with authentication. I parse response from authentication wsdl, catch cookies and added there to the next query – Gorets Mar 01 '12 at 09:23