【发布时间】:2009-05-25 11:39:49
【问题描述】:
我正在尝试通过 WCF 控制台应用程序使用服务。但我得到的唯一响应是“远程服务器返回了意外响应:(400) 错误请求。”
服务配置有以下选项:
<services>
<service name="TryOut.BasicService" behaviorConfiguration="NicksBasicBehavior">
<host>
<baseAddresses>
<add baseAddress="http://192.168.10.67:8000/Service" />
</baseAddresses>
</host>
<endpoint address ="http://192.168.10.67:8000/Service"
name="NicksEndpoint"
binding="basicHttpBinding"
contract="TryOut.IBasicService"
bindingConfiguration="BasicBinding"
/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="NicksBasicBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<binding name="BasicBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
我的客户端的配置文件如下:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NicksEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.10.67:8000/Service" binding="basicHttpBinding"
bindingConfiguration="NicksEndpoint" contract="ServiceReference1.IBasicService"
name="NicksEndpoint" />
</client>
现在,当我在与服务相同的 PC 上启动客户端时,一切正常。但是,如果我尝试在不在服务器 PC 域中的机器上运行客户端,则会出现错误,尽管我在客户端代码中提供了登录信息:
c.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("Nick", "password", "mydomain");
有人知道我做错了什么,我该如何解决?谢谢你的期待!
【问题讨论】:
标签: c# wcf authentication