2012-02-28 6 views
2

私は以下を参照してください:SPサーバーへのSOAP 1.1リクエストのサンプルですが、それは重要ではありません。SOAPコンテンツの長さ

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:長さは、実際の値と交換する必要があります。その価値は何ですか?私はどこでそれを見ることができますか?またはリクエスト前に値を計算する方法は?

UPD1。 私はContent-Length値が第一<で始まり、ここで>または多分ボディの最後の文字、改行で終わる体の長さ(バイト単位)である

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

どのようにSOAPリクエストを作成していますか? – McDowell

+0

このリンクはあなたに役立ちます http://stackoverflow.com/questions/290172/calculating-soap-content-length – Xara

+0

私は** transport.call(SOAP_ACTION、envelope、headerList)で完全なクエリを見ることができます; **しかし、私はこのメソッドの前にcalcコンテンツの長さが必要です。 – Gorets

答えて

2

私はこの問題を解決しました。私は自分自身に

 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のために役に立てば幸い、私のために助けたように私は、callメソッドを再ロードされたクラス

public class MyHttpTransportSE extends Transport 

を書きました。

1

libにksoap使用しています。

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/

+0

私の封筒のヘッダーには、前のクエリのトークンを追加する必要があります。私は他のデータを持っていない彼らはトークンは、SharePoint Serverに認証データを持つクッキー。 – Gorets

+0

編集されました。 '多分それは助けます – Alfabravo

+0

私は認証の問題を解決しました。私は認証wsdlからの応答を解析し、クッキーを捕まえて次のクエリに追加しました – Gorets

関連する問題