我想在Web服务上实现wsHTTPBinding,但我不断收到此错误:
“呼叫者未通过服务验证”。我已经看到了大量关于此主题的帖子,但是它们要么不能解决我的问题/与我的配置无关,要么“答案”是使用basicHTTPBinding。
该服务托管在带有自己的ssl证书的安全网站的根文件夹中。我希望我可以使用该证书来合理地保护SOAP消息,这就是为什么我要坚持使用wsHTTP。但是,我尝试过修改各种配置-甚至将身份验证模式设置为“ none”只是为了使其正常工作-但每次遇到相同的错误时,我都会尝试。
有谁知道我该如何修改web.config设置以使wsHTTPBinding使用现有的ssl证书来工作?
Web.config
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<trust level="Full"></trust>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="xxxService1.xxx1Behavior" name="xxxService1.xxx1">
<endpoint address=""
binding="basicHttpBinding"
contract="xxxService1.Ixxx1"
bindingConfiguration="secureHttpBinding"
>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="xxxService1.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="xxxService1.xxx1Behavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime version="v4.0.20506"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://111.111.111.111/xxxAPI/xxx1.svc"
binding="basicHttpBinding"
contract="TestingxxxService1.Ixxx1"
name="BasicHttpBinding_Ixxx1"
bindingConfiguration="secureHttpBinding" />
</client>
</system.serviceModel>
</configuration>
最佳答案
您需要发布客户端和服务器配置。配置取决于您想要用于身份验证的凭据。要通过HTTP绑定(BasicHttpBinding或WsHttpBinding)使用SSL,安全模式将为Transport或TransportWithMessageCredential。为什么为此需要WsHttpBinding?
这里有很多不同的配置选项:
http://msdn.microsoft.com/en-us/library/ms789011%28v=vs.110%29.aspx
一个例子:
<wsHttpBinding>
<binding name="WsHttpBinding_ICalculator">
<security mode="TransportWithMessageCredential" >
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>