肥皂共享点信封
我尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标头数据在 HTTP 标头中发送,而不是在 SOAP 主体中发送,这就是他们称之为标头的原因。当您使用“HTTP 基本”身份验证时,会添加一个
Authorization
标头。请参阅维基百科的示例:http://en.wikipedia.org/wiki/Basic_access_authentication#ExampleHeader 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