简体   繁体   English

来自ASP.NET Project的SharePoint自定义WebService调用

[英]SharePoint custom WebService call from ASP.NET Project

I am trying to use custom webservice deployed on SharePoint server. 我正在尝试使用SharePoint服务器上部署的自定义Web服务。 I have added proxy class for WebService in my project. 我在项目中添加了WebService的代理类。

I am passing correct credentials to connect to WebService call, when I am trying to invoke method from WebService class, it is redirecting to Login page and sending HTML Code in response for login page. 我正在传递正确的凭据以连接到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);

Thanks, Nikhil. 谢谢,尼克希尔。

It looks like your SharePoint Server Web Application has Forms Based Authentication. 看起来您的SharePoint Server Web应用程序具有基于表单的身份验证。 When you define webServiceObj.Credentials you will use Windows Authentication, while the service expects Forms Based. 定义webServiceObj.Credentials时,将使用Windows身份验证,而该服务需要基于表单的形式。

To call service in your Authentication scenario you need: 要在身份验证方案中致电服务,您需要:

  1. Call Authentication.asmx web service to get CookieContainer 调用Authentication.asmx Web服务获取CookieContainer

  2. Assign CookieContainer to your webServiceObj.CookieContainer 将CookieContainer分配给您的webServiceObj.CookieContainer

  3. Call service 通话服务

I found this article that describes it perfectly http://www.tonytestasworld.com/post/2009/06/04/How-To-Authenticate-and-Use-SharePoint-Web-Services-in-an-FBA-SharePoint-site.aspx 我发现这篇文章对其进行了完美的描述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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM