0

刚开始使用对 SharePoint(2010) 的 Web 服务调用并进行调用GetWebCollection,并且GetListCollection正常工作并返回预期的数据。运行GetListCollection按预期返回所有 SP 列表。

<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>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>

从返回的 SP 列表中,我提取日历列表的内部名称 {A2CEBD3C-D07A-44A3-BE34-975AFE57F56C}

<_sList>
    <InternalName>{A2CEBD3C-D07A-44A3-BE34-975AFE57F56C}</InternalName>
    <Title>Calendar</Title>
    …..

当我尝试GetList使用该 ID 值拨打电话时,我的问题出现了:

NSString *soapFormat = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                        "<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/\">\n"
                        "<soap:Body>\n"
                        "<GetList xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />\n"
                        "<listName>{A2CEBD3C-D07A-44A3-BE34-975AFE57F56C}</listName>\n"
                        "</GetList>\n"
                        "</soap:Body></soap:Envelope>\n"];


    NSLog(@"Request is : %@",soapFormat);

    NSURL *locationOfWebService = [NSURL URLWithString:@"http://192.168.0.114/_vti_bin/lists.asmx"];

    NSLog(@"Web url = %@",locationOfWebService);

    NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc]initWithURL:locationOfWebService];

    NSString *msgLength = [NSString stringWithFormat:@"%d",[soapFormat length]];


    [theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue:@"http://schemas.microsoft.com/sharepoint/soap/GetList"
                            forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];

当我在 iPad 5.1 模拟器中运行它时,GetList调用会进行身份验证并连接,但会返回 0 个字节。

2013-01-05 13:31:56.053 SoapSharePoint[1936:c07] Request is : <?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>{A2CEBD3C-D07A-44A3-BE34-975AFE57F56C}</listName>
</GetList>
</soap:Body></soap:Envelope>
2013-01-05 13:31:56.055 SoapSharePoint[1936:c07] Web url = http://192.168.0.114/_vti_bin/lists.asmx
2013-01-05 13:31:56.059 SoapSharePoint[1936:c07] Connected...
2013-01-05 13:31:56.136 SoapSharePoint[1936:c07] Received Auth Req.
2013-01-05 13:31:56.147 SoapSharePoint[1936:c07] Received 0 Bytes!
2013-01-05 13:31:56.147 SoapSharePoint[1936:c07]

在另一个工作站上使用 Fiddler 并使用 U2U CAML Query Builder 我可以看到 U2U 产品问题 a GetListCollectionGetAllSubWebCollections当它启动时(现在知道所有站点和列表),当我双击日历列表时,他们发送此SOAP请求:

POST http://g2010/_vti_bin/lists.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.5466)
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetList"
Host: g2010
Content-Length: 378
Expect: 100-continue
Connection: Keep-Alive

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<listName>{A2CEBD3C-D07A-44A3-BE34-975AFE57F56C}</listName>
</GetList>
</soap:Body>
</soap:Envelope>

这将返回列表字段,并允许我构建一个CAML查询,然后返回日历列表中的 2 个项目。我不明白为什么我的电话GetList没有返回任何数据,并希望有人能发现我的明显错误:-)

谢谢!

4

1 回答 1

1

这种解释可能有点矫枉过正,但不是不清楚。您GetList的代码在代码块中过早结束。

<GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
    <listName>{A2CEBD3C-D07A-44A3-BE34-975AFE57F56C}</listName>
</GetList>

第一个 GetList 标记上的最后一个 / 确保GetList立即关闭。写作<GetList />和写作一样<GetList></GetList>。所以你的代码块被视为:

<GetList xmlns="http://schemas.microsoft.com/sharepoint/soap/" >
</GetList>
<listName>{A2CEBD3C-D07A-44A3-BE34-975AFE57F56C}</listName>
</GetList>

其中前两行是GetList没有 listName 的行,第三行是 listName 但GetList周围不再有任何内容,第四行是“GetList 结束”标签,什么都不做。

删除第一个GetList标签中的最后一个/应该使一切正常:-)

于 2013-02-19T13:22:20.420 回答