我在调试SharePoint SOAP调用以创建列表项时遇到了很大的困难。我发送的SOAP主体是:
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:UpdateListItems>
<ns1:listName>{35BC2CB3-D2FB-4D47-B711-7502819D6E2B}</ns1:listName>
<ns1:updates>
<Batch OnError="Continue" ListVersion="1">
<Method ID="1" Cmd="New">
<Field Name="ID">New</Field>
<Field Name="Title">Test Summary</Field>
</Method>
</Batch>
</ns1:updates>
</ns1:UpdateListItems>
</ns0:Body>
</SOAP-ENV:Envelope>无论我做什么,我总是得到一个SoapServerException,其中包含“值不在预期范围内”作为详细信息。这是在我有完全访问权限的SharePoint站点上。这是一个新创建的列表,其中Title是唯一必需的属性。我如何找出问题所在?
顺便说一句,我对其他方法,如GetList和GetListItems没有问题。我只是在使用UpdateListItems添加一个新的列表项时运气不佳。
发布于 2014-01-28 09:26:04
TLDR:在尝试第一次更新调用之前尝试设置client.options.prettyxml = True。
天哪,我已经为一个明显相同的问题纠结了一整天了。假设您使用的是类似的suds版本(这里是suds_jurko 0.5 ),那么“如何更好地调试这个?”在某种程度上,是在记录:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)sax文档/元素(或相邻元素)中的某个地方存在一个bug,导致"element.plain()“函数认为该元素为空。当str()为False时,SoapClient.send()会尝试使用sax文档的'plain()‘方法,而不是client.options.prettyxml ()方法。这样做的结果是元素被解析为空,从而导致UpdateListItems失败,并显示错误"Value as not秋季of The expected range,“。
例如:
MESSAGE:
b'<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns0:Body>
<ns1:UpdateListItems>
<ns1:listName>B5E50422-D16B-4C5F-AE19-CFBE943C6F3F</ns1:listName>
<updates/>
</ns1:UpdateListItems>
</ns0:Body>
</SOAP-ENV:Envelope>'请注意,GetListItems()方法对我也“有效”,因为sax在SOAP调用中放入了一个空的查询元素,这在技术上是很好的。
要解决这个问题,可以在调用第一个服务之前通过在某个地方添加client.options.prettyxml = True来强制SoapClient.send()使用'pretty‘版本。
我没有注意到这个错误,因为我显然是在SOAP对象被损坏之前检查它;打开日志记录会显示最后一分钟的更改。
(我意识到这是一个老问题,不确定这是不是不受欢迎;但这是我之前能找到的最接近我实际问题的问题,我觉得它值得一个答案)
发布于 2012-08-24 03:06:41
我自己也有这个问题。
这是我使用的代码,它似乎起作用了:
batch = Element('Batch').append(Attribute('OnError', 'Return'))
batch.append(Attribute('ListVersion', '1'))
method = Element('Method').append(Attribute('ID', '1'))
method.append(Attribute('Cmd', 'Update'))
method.append(Element('Field').append(Attribute('Name', 'ID')).setText(1))
method.append(Element('Field').append(Attribute('Name', 'Title')).setText('Just Changed It23223'))
batch.append(method)
updates = Element('ns1:updates')
updates.append(batch)
client.service.UpdateListItems('Test', updates)发布于 2011-05-05 14:05:59
请确保您的列表ID正确,并且字段仅对您要添加项目的列表使用内部名称。
尝试将您的方法放在Try catch块中。将其放在catch块的下面,以获得异常的更多详细信息。
catch (soapserver.soapserverexception ex)
{
console.writeline(ex.detail.innertext);
}https://stackoverflow.com/questions/5889297
复制相似问题