肥皂共享点信封

发布于 2025-01-08 14:42:42 字数 2355 浏览 0 评论 0原文

我尝试使用 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>

头数据在哪里?也许它会添加到调用方法中? 它是正确的信封吗? 我在服务器授权方面也犯了与上一篇文章相同的错误。

I try to construct a correct soap envelope used 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();
...

In debug mode I see this envelope:

  <?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>

Where is header data? Maybe its will be add in the call method?
Its a correct envelope?
And I had the same mistakes from my previous post with authorization in server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2025-01-15 14:42:42

标头数据在 HTTP 标头中发送,而不是在 SOAP 主体中发送,这就是他们称之为标头的原因。当您使用“HTTP 基本”身份验证时,会添加一个 Authorization 标头。请参阅维基百科的示例:http://en.wikipedia.org/wiki/Basic_access_authentication#Example

Header data is sent in HTTP headers, not in SOAP body, that is why they call it headers. When you use "HTTP basic" authentication, an Authorization header is added. See an example from Wikipedia: http://en.wikipedia.org/wiki/Basic_access_authentication#Example

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文