[英]SharePoint custom WebService call from ASP.NET Project
我正在嘗試使用SharePoint服務器上部署的自定義Web服務。 我在項目中添加了WebService的代理類。
我正在傳遞正確的憑據以連接到WebService調用,當我嘗試從WebService類調用方法時,它將重定向到“登錄”頁面並發送HTML代碼以響應登錄頁面。
//Code for using webservice
var webServiceObj = new MyWebService();
webServiceObj.Credentials = new NetworkCredential(Constants.UserName_Cridentials, Constants.Password_Cridentials, Constants.DomainName_Cridentials);
var result = webServiceObj.GetWeekReport(ID, Date);
謝謝,尼克希爾。
看起來您的SharePoint Server Web應用程序具有基於表單的身份驗證。 定義webServiceObj.Credentials時,將使用Windows身份驗證,而該服務需要基於表單的形式。
要在身份驗證方案中致電服務,您需要:
調用Authentication.asmx Web服務獲取CookieContainer
將CookieContainer分配給您的webServiceObj.CookieContainer
通話服務
我發現這篇文章對其進行了完美的描述http://www.tonytestasworld.com/post/2009/06/04/How-To-Authenticate-and-Use-SharePoint-Web-Services-in-an-FBA-SharePoint- site.aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.