要用 HTTPS。
用的就是https啊
@紫陌轻风: Endpoint Address 是啥?
@Launcher: <endpoint address="" binding="wsHttpBinding" bindingConfiguration="LxWsHttpBinding" contract="LxContracts.IBookContract"></endpoint>
因为我是搭载在IIS上的
@紫陌轻风: 你这段代码是运行在 IIS 上的?
@Launcher: 是服务搭载在IIS上,客户端的endpoint
<client>
<endpoint address="https://cn--20141114fqe:9010/BookSrv.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBookContract"
contract="WCF.Service.IBookContract" name="WSHttpBinding_IBookContract" behaviorConfiguration="cnt2Behavior" />
</client>
@紫陌轻风: 客户端的 binding 配置是啥?
@Launcher: 整个servicemodel发给你看好了
@Launcher:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="cnt2Behavior">
<clientCredentials>
<clientCertificate storeName="My" x509FindType="FindBySubjectName" findValue="Client2-PC" storeLocation="CurrentUser"/>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IBookContract">
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://cn--20141114fqe:9010/BookSrv.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBookContract"
contract="WCF.Service.IBookContract" name="WSHttpBinding_IBookContract" behaviorConfiguration="cnt2Behavior" />
</client>
</system.serviceModel>
@紫陌轻风: clientCredentials 中缺少 serviceCrtificate 的设置
@Launcher: 写成这样?
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="Custom" customCertificateValidatorType="Client2.vailtor,Client2"/>
</serviceCertificate>
<clientCertificate storeName="My" x509FindType="FindBySubjectName" findValue="Client2-PC" storeLocation="CurrentUser"/>
</clientCredentials>
@紫陌轻风: 你咋能随便乱改呢?你服务器的安全模式是咋设置的?
@Launcher: 我刚学不久...我服务端设置
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="LxBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceCredentials>
<clientCertificate>
<authentication customCertificateValidatorType="HostWeb_Server.Vailtor,HostWeb_Server" certificateValidationMode="Custom" />
</clientCertificate>
<serviceCertificate findValue="CN--20141114FQE" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="LxWsHttpBinding">
<security mode="Transport">
<transport clientCredentialType="Certificate"></transport>
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="LxServices.BookService" behaviorConfiguration="LxBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="LxWsHttpBinding" contract="LxContracts.IBookContract"></endpoint>
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
你的iis有没有enable anonymous authentication