Получилось вызвать самые простые веб-матоды моего веб-сервиса способом, подсказанным a33ik.
Возникла следующая проблема:
веб-методы, в которых не используется доступ к структуре шарапойнт отрабатывает хорошо
X++:
[WebMethod]
public string HelloWorld1(string sitePath, string libName, string folderPath, string fileName, byte[] fileContents)
{
SPSite site = new SPSite(sitePath);
SPWeb web = site.OpenWeb();
return sitePath;
}
При небольшом изменении (см. пример ниже) - кидается ошибка
"The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'."
X++:
[WebMethod]
public string HelloWorld1(string sitePath, string libName, string folderPath, string fileName, byte[] fileContents)
{
SPSite site = new SPSite(sitePath);
SPWeb web = site.OpenWeb();
string libRoot = web.Lists[libName].RootFolder.ServerRelativeUrl.ToString();
return sitePath;
}
Приложение sharepoint работает под пользователем domen\user, который является администратором на компьютере, в sharepoint и crm.
ОС: windows 2003, IIS 6.0
Доступ к вебслужбе осуществляется так:
X++:
BasicHttpBinding bind = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
EndpointAddress endpoint = new EndpointAddress("http://server:6001/_vti_bin/Files.asmx");
bind.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
bind.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
bind.SendTimeout = new TimeSpan(0, 1, 0);
bind.ReceiveTimeout = new TimeSpan(0,10,0);
bind.OpenTimeout = new TimeSpan(0, 1, 0);
bind.CloseTimeout = new TimeSpan(0, 1, 0);
bind.MaxBufferPoolSize = 5524288;
bind.MaxBufferSize = 565536;
bind.MaxReceivedMessageSize = 565536;
SharepointConnector.FilesSoapClient connector = new SharepointConnector.FilesSoapClient(bind, endpoint);
connector.ClientCredentials.UserName.UserName = @"domen\user";
connector.ClientCredentials.UserName.Password = "****";
connector.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
[...]
// Тут валится
connector.HelloWorld1("http://server:6001", "Библиотека документов", "/Папка1/Папка2/Папка3", "qwe.txt", buffer);
В консольном же приложении все отрабатывает хорошо.
Помогите пожалуйста!