当前的project中有web service的引用,其配置如下:
<system.serviceModel> <bindings> <basicHttpBinding> <binding name="ReceiveInterfaceAppUpdatesSoap" ... useDefaultWebProxy="true"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Basic" proxyCredentialType="Windows" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="..." binding="basicHttpBinding" bindingConfiguration="ReceiveInterfaceAppUpdatesSoap" contract="..." name="..." /> </client> </system.serviceModel>
client的调用如下:
.... // 服务代理
ServiceClient proxy=new ServiceClient(); // 设置账户和密码
proxy.ClientCredentials.Windows.ClientCredentials.UserName="..."; proxy.ClientCredentials.Windows.ClientCredentials.Password="..."; //invoke
当调用的服务时,总是出现异常。经过测试发现,<transport>节点的不同配置将导致不同的异常。现在知道webservice授权的账户和密码,但始终不能正常调用。
我猜测服务端使用的是windows授权机制,但是不知道在client端的config文件如何配置,尤其是<transport>节点的配置?请园友指点!