C# wcf client.exception“提供的URI方案“http”无效;应为“https”
我正在创建客户端到WCF服务。服务在SharePoint上运行我不知道,但也许这很重要 配置:C# wcf client.exception“提供的URI方案“http”无效;应为“https”,c#,wcf,service,client,C#,Wcf,Service,Client,我正在创建客户端到WCF服务。服务在SharePoint上运行我不知道,但也许这很重要 配置: <system.serviceModel> <bindings> <basicHttpBinding> <binding name="CommonServiceJSSoap_binding" > <security mode="Transport">
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="CommonServiceJSSoap_binding" >
<security mode="Transport">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://blackwhite/_layouts/15/eos/commonservicejs.asmx"
binding="basicHttpBinding" bindingConfiguration="CommonServiceJSSoap_binding"
contract="CommonServices.CommonServiceJSSoap" name="CommonServiceJSSoap_endpint" />
</client>
</system.serviceModel>
Open throw ArgumentException{提供的URI方案“http”无效;应为“https”。\r\n参数名称:via}
CommonServiceJSSoapClient是自动生成的visual studioVS添加服务引用
匿名访问被拒绝。
如果信息不充分,请写信给我评论
谢谢。Sharepoint需要身份验证。这取决于Sharepoint管理员如何设置安全性 每当我们在未启用匿名登录的情况下打开SharePoint网站时,该网站将提示用户凭据。当我们通过web服务调用时,提示对话框将不起作用。我们需要使用名为credentials的属性传递凭据
client.Credentials = new NetworkCredential("appes", "password"); / // using System.Net;
以下是有关某些身份验证表单的一些代码:
protected void AuthenticateWindowsClassic(string domain, string userName, string password)
{
if (userName != null && userName.Length > 0)
{
api.Credentials = new System.Net.NetworkCredential(userName, password, domain);
}
else
{
api.Credentials = System.Net.CredentialCache.DefaultCredentials;
}
// Verify set credentials.
System.Net.NetworkCredential cred = (System.Net.NetworkCredential) api.Credentials;
Console.WriteLine(@"Credentials set to: {0}\{1}", cred.Domain, cred.UserName);
}
protected bool AuthenticateFBAClaims(string userName, string password)
{
FBA.Authentication spAuthentication = new FBA.Authentication();
spAuthentication.Url = farmURL + "_vti_bin/Authentication.asmx";
spAuthentication.CookieContainer = new CookieContainer();
FBA.LoginResult loginResult = spAuthentication.Login(userName, password);
authCookie = new Cookie();
// Determines if login is successful.
if (loginResult.ErrorCode == FBA.LoginErrorCode.NoError)
{
// Get the cookie collection from the authenticating Web service.
CookieCollection cookies = spAuthentication.CookieContainer.GetCookies(new Uri(spAuthentication.Url));
// Get the specific cookie that contains the security token.
authCookie = cookies[loginResult.CookieName];
// Initialize the cookie container of Excel Web Services.
api.CookieContainer = new CookieContainer();
api.CookieContainer.Add(authCookie);
return true;
}
else
{
return false;
}
}
以下是两个分步教程:
在绑定安全模式下,仅使用TransportCredential而不是Transport
protected void AuthenticateWindowsClassic(string domain, string userName, string password)
{
if (userName != null && userName.Length > 0)
{
api.Credentials = new System.Net.NetworkCredential(userName, password, domain);
}
else
{
api.Credentials = System.Net.CredentialCache.DefaultCredentials;
}
// Verify set credentials.
System.Net.NetworkCredential cred = (System.Net.NetworkCredential) api.Credentials;
Console.WriteLine(@"Credentials set to: {0}\{1}", cred.Domain, cred.UserName);
}
protected bool AuthenticateFBAClaims(string userName, string password)
{
FBA.Authentication spAuthentication = new FBA.Authentication();
spAuthentication.Url = farmURL + "_vti_bin/Authentication.asmx";
spAuthentication.CookieContainer = new CookieContainer();
FBA.LoginResult loginResult = spAuthentication.Login(userName, password);
authCookie = new Cookie();
// Determines if login is successful.
if (loginResult.ErrorCode == FBA.LoginErrorCode.NoError)
{
// Get the cookie collection from the authenticating Web service.
CookieCollection cookies = spAuthentication.CookieContainer.GetCookies(new Uri(spAuthentication.Url));
// Get the specific cookie that contains the security token.
authCookie = cookies[loginResult.CookieName];
// Initialize the cookie container of Excel Web Services.
api.CookieContainer = new CookieContainer();
api.CookieContainer.Add(authCookie);
return true;
}
else
{
return false;
}
}