Question

Je fais ma deuxième application pour la plate-forme de la série Windows Phone 7 et je ne peux pas sembler se connecter à un serveur SharePoint en utilisant https.

99% des éléments suivants ne sont pas mon code. Je l'ai emprunté à http :. //blog.daisley-harrison.com/blog/post/Practical-Silverlight-and-SharePoint-Integration-Part-Two.aspx jusqu'à ce que je peux mieux comprendre comment fonctionne SOAP dans la série W7P

Je sais que je besoin d'un moyen d'envoyer des informations d'identification sur l'API, mais la victoire 7 ne semble pas vous laisser. 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>

Ceci est ma page maincode:

    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); }
        }
    }

Quand je lance cela et il arrive à la partie « ListsSoapClient », il se casse. Si vous creuser dans la sortie d'erreur, il indique l'accès est refusé. J'ai essayé différentes méthodes d'envoi des informations d'identification, mais aucun ne semble fonctionner. « ClientCredentials.Windows » est pas pris en charge et ClientCredentials.UsersName.Username est en lecture seule.

Était-ce utile?

La solution

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top