3

Sharepoint に接続するための iOS iPad アプリを開発しています。私はこれを ASIHTTPRequest フレームワークで行っています。私のコードは次のようになります。

NSURL *url = [NSURL URLWithString:@"https://SHAREPOINTURL"];

NSString *soapMessage = @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n"
"<soap12:Body>\n"
"<GetListCollection xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\" />\n"
"</soap12:Body>\n"
"</soap12:Envelope>\n";

asiRequest = [ASIHTTPRequest requestWithURL:url];

[asiRequest setUsername:@"USERNAME"];
[asiRequest setPassword:@"PASSWORD"];

[asiRequest setDelegate:self];
[asiRequest appendPostData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[asiRequest addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];
[asiRequest startAsynchronous];

ここまでは順調ですが、これをデバッグすると 403 FORBIDDEN エラーが発生します。なんで?私の意見では、間違いはユーザー名とパスワードではないと思います。リクエストに何か問題があるのでしょうか?

4

2 に答える 2

0

あなたはあなたの URL を投稿していないので、あなたは に投稿しています_vti_bin/authentication.asmxか?

既にお持ちの場合は、ASI がログイン情報を正しく入力しているかどうかわからないため、これを提案することしかできません。次のようにSOAPメッセージに手動で入れてみてください: (ここから)

<?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>
    <Login xmlns="http://schemas.microsoft.com/sharepoint/soap/">
      <username>USERNAME</username>
      <password>PASSWORD</password>
    </Login>
  </soap:Body>
</soap:Envelope>

これにより、残りの Web サービスを使用するために必要なログイン Cookie が返されます。

編集:もう1つ、SPサーバーをNTLM認証(デフォルト)ではなくフォーム認証を使用するように設定する必要があります。

于 2012-12-18T19:52:17.777 に答える