【发布时间】:2012-07-18 08:13:36
【问题描述】:
我有一个服务类:
namespace TestService
{
public class Service:IService
{
#region IService Members
public string TestCall()
{
return "You just called a WCF webservice On SSL(Transport Layer Security)";
}
#endregion
}
}
和配置服务:
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="returnFaults" name="TestService.Service">
<endpoint binding="wsHttpBinding" bindingConfiguration="TransportSecurity" contract="TestService.IService"/>
<endpoint address="mex" binding="mexHttpsBinding" name="MetadataBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpsGetEnabled="true"/>
<serviceTimeouts/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<diagnostics>
<messageLogging logEntireMessage="true" maxMessagesToLog="300" logMessagesAtServiceLevel="true" logMalformedMessages="true" logMessagesAtTransportLevel="true"/>
</diagnostics>
</system.serviceModel>
</configuration>
我为 IIS 设置了服务,并为服务设置了 http、https 在 https:“https://localhost/service.svc” 和 http:“http://localhost/service.svc” 设置 https 时,我设置了证书“WCFServer”。我可以访问地址“https://localhost/service.svc”的服务。 我在地址“https://localhost/service.svc”添加服务引用并调用服务:
ServiceReference1.ServiceClient proxy = new ServiceReference1.ServiceClient();
proxy.TestCall();
返回错误:
远程证书根据验证无效 过程。
这个配置客户端:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://thanguk-pc/service.svc" binding="wsHttpBinding" behaviorConfiguration="firstSsl"
bindingConfiguration="WSHttpBinding_IService" contract="ServiceReference1.IService"
name="WSHttpBinding_IService" >
<identity>
<dns value="WcfServer" />
</identity>
</endpoint>
</client>
<behaviors>
<endpointBehaviors>
<behavior name="firstSsl">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="None" revocationMode="NoCheck"/>
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
客户使用服务有什么问题?谢谢
【问题讨论】:
-
这能解决您的问题吗? stackoverflow.com/questions/3453125/…
-
感谢弗莱姆,但我没有找到解决方案
标签: c# wcf web-services