Windows Phone 7は、SOAPを介してSharePointに接続します
-
21-09-2019 - |
質問
Windows 7 Phoneシリーズプラットフォームの2番目のアプリケーションを作成していますが、HTTPSを使用してSharePointサーバーに接続することはできません。
以下の99%は私のコードではありません。私はそれを借りました http://blog.daisley-harrison.com/blog/post/practical-silverlight-and-sharepoint-integration-part-two.aspx W7PシリーズでSOAPがどのように機能するかをさらに理解できます。
資格情報を送信する方法が必要であることは知っていますが、Win 7 APIはあなたを許していないようです。ServicEreferences.ClientConfig
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ViewsSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Buffered">
<security mode="TransportCredentialOnly"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://my.secureconnection.com/_vti_bin/views.asmx"
binding="basicHttpBinding" bindingConfiguration="ViewsSoap"
contract="SharePointListService.ViewsSoap" name="ViewsSoap" />
</client>
</system.serviceModel>
</configuration>
これは私のメインコードページです:
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;
try
{
Uri serviceUri = new Uri("https://my.secureconnection.com" + SERVICE_LISTS_URL);
BasicHttpBinding binding;
if (serviceUri.Scheme == "https")
{
binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
}
else
{
binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
}
EndpointAddress endpoint = new EndpointAddress(serviceUri);
ListsSoapClient listSoapClient = new ListsSoapClient(binding, endpoint);
NetworkCredential creds = new NetworkCredential("administrator", "iSynergy1", "server001");
//listSoapClient.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Identification;
//listSoapClient.ClientCredentials.Windows.ClientCredential = creds;
listSoapClient.GetListCollectionCompleted += new EventHandler<GetListCollectionCompletedEventArgs>(listSoapClient_GetListCollectionCompleted);
listSoapClient.GetListCollectionAsync();
}
catch (Exception exception)
{
handleException("Failed to get list collection", exception);
}
}
#region ShowExceptionDetail Property
public static readonly DependencyProperty ShowExceptionDetailDependencyProperty = DependencyProperty.Register("ShowExceptionDetail",typeof(bool),typeof(Page),new PropertyMetadata(true));
public bool ShowExceptionDetail
{
get { return (bool)GetValue(ShowExceptionDetailDependencyProperty); }
set { SetValue(ShowExceptionDetailDependencyProperty, value); }
}
#endregion
private void handleException(string context, Exception exception)
{
this.Dispatcher.BeginInvoke(delegate()
{
bool showExceptionDetail = this.ShowExceptionDetail;
string message = "";
Exception next = exception;
do
{
if (message.Length > 0) { message += ";" + Environment.NewLine; }
if (next.Message == null || next.Message.Length == 0) { message += next.GetType().FullName; }
else { message += next.Message; }
if (showExceptionDetail)
{
if (next.Data.Count > 0)
{
bool first = true;
message += " {";
foreach (string key in next.Data.Keys)
{
if (first) { first = false; }
else { message += ", "; }
message += key + "=\"" + next.Data[key] + "\"";
}
message += "}";
}
if (next.InnerException != next)
{
next = next.InnerException;
continue;
}
}
next = null;
}
while (next != null);
MessageBox.Show(message, context, MessageBoxButton.OK);
});
}
private const string SERVICE_LISTS_URL = "/_vti_bin/lists.asmx";
void listSoapClient_GetListCollectionCompleted(object sender, GetListCollectionCompletedEventArgs e)
{
try { myList.Text = e.Result.ToString(); }
catch (Exception exception) { handleException("Failed to get list collection", exception); }
}
}
私がこれを実行し、「listssoapclient」部分に到達すると、壊れます。エラー出力を掘り下げると、アクセスが拒否されていると表示されます。資格情報を送信するさまざまな方法を試しましたが、うまくいかないようです。 「ClientCredentials.Windows」はサポートされておらず、ClientCredentials.usersName.usernameは読み取り専用です。
解決
Microsoftは、NTLMがSDKでまだサポートされていないことを確認しました。 http://social.msdn.microsoft.com/forums/en-us/windowsphone7series/thread/43a84dff-9447-4e95-8040-8a5447514fa0
アップデート
誰かが回避策を見つけたようです http://zetitle.wordpress.com/2010/03/30/wp7-connecting-tat-web-services-that-usuthentication/