我正在Visual Studio中开发一个Web应用程序,该Web应用程序使用Intranet中的Master Data Services Web服务。
在本地模式下,此应用程序正确执行,并且在将应用程序发布到现在托管了Master Data Web服务的另一台服务器上时,出现“访问被拒绝”的问题。
用于配置serviceClient的代码为:
private static ServiceClient createMdsProxy(string mdsURL) /
{
EndpointAddress pntFinalAddress = new EndpointAddress(new Uri(mdsURL), EndpointIdentity.CreateUpnIdentity("@etnas.conts.net"));
WSHttpBinding wsBinding = new WSHttpBinding();
wsBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
wsBinding.Security.Mode = SecurityMode.Message;
wsBinding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
wsBinding.Security.Message.NegotiateServiceCredential = true;
wsBinding.Security.Message.EstablishSecurityContext = true;
wsBinding.MaxReceivedMessageSize = 2147483646;
wsBinding.MaxBufferPoolSize = 2147483646;
return new ServiceClient(wsBinding, pntFinalAddress);
}
在其他方法中,我称为createMdsProxy方法:
mdsproxy = createMdsProxy("http://arwdw20.etnas.conts.net:8001/service/Service.svc");
客户端的web.config文件是使用Visual Studio中的服务引用自动生成的:
<configuration> <system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IService"/>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://arwdw20.etnas.conts.net:8001/service/Service.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService" contract="IService" name="WSHttpBinding_IService">
<identity>
<userPrincipalName value="DSSService@itnes.conts.net"/>
</identity>
</endpoint>
<endpoint address="http://arwdw20.etnas.conts.net:8001/service/Service.svc/bhb" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService" contract="IService" name="BasicHttpBinding_IService"/>
</client> </system.serviceModel> <system.web> <compilation debug="true"/> </system.web></configuration>
这是WSDL文件的一部分,其中包含服务信息和连接:
托管我的Web应用程序的方向:http://arw15.etnas.conts.net/InitiativesForm.aspx
您无法访问,但为了方便起见,请放上它
我已阅读过使用WCF身份验证,但无法成功建立连接。
非常感谢!