Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soap content length

Tags:

java

soap

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);
like image 819
Gorets Avatar asked Jul 10 '26 01:07

Gorets


2 Answers

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.

like image 69
Gorets Avatar answered Jul 11 '26 15:07

Gorets


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.

like image 33
Florent Guillaume Avatar answered Jul 11 '26 14:07

Florent Guillaume



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!