c# – 使用wsHttpBinding配置WCF服务

c# – 使用wsHttpBinding配置WCF服务,第1张

概述我在使用 wsHttpBinding和Https基地址设置WCF服务时遇到问题. 真正的问题是在客户端测试WCF中定义mex时: 错误:无法从中获取元数据 https://localhost:8722/Design_Time_Addresses/_20180420_WcfServiceLibraryTest/Service1/mex 如果这是您有权访问的Windows(R)Communicatio 我在使用 wsHttpBinding和https基地址设置WCF服务时遇到问题.

真正的问题是在客户端测试WCF中定义mex时:

错误:无法从中获取元数据
https://localhost:8722/Design_Time_Addresses/_20180420_WcfServiceLibraryTest/Service1/mex
如果这是您有权访问的windows(R)Communication Foundation服务,请检查您是否已在指定地址启用元数据发布.
有关启用元数据发布的帮助,请参阅http://go.microsoft.com/fwlink/?LinkId=65455中的MSDN文档.

App.config:

<system.serviceModel>    <behaviors>        <serviceBehaviors>            <behavior name="NewBehavior0"> <!-- Error: Cannot optain Metadata -->                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />                <serviceDeBUG includeExceptionDetailinFaults="true" />            </behavior>            <behavior name="NewBehavior1"> <!-- Error: Cannot Find Cert -->              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />              <serviceDeBUG includeExceptionDetailinFaults="true" />              <serviceCredentials>                <serviceCertificate  findValue="BadThumbprint" x509FindType="FindByThumbprint"  storeLocation="LocalMachine" storename="My"/>              </serviceCredentials>            </behavior>            <behavior name="NewBehavior2"> <!-- Error: Cannot optain Metadata -->              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />              <serviceDeBUG includeExceptionDetailinFaults="true" />              <serviceCredentials>                <serviceCertificate  findValue="GoodThumbprint" x509FindType="FindByThumbprint"  storeLocation="LocalMachine" storename="My"/>              </serviceCredentials>            </behavior>                     </serviceBehaviors>    </behaviors>    <bindings>        <wshttpBinding>            <binding name="wshttpBindingConf">                <security mode="Transport">                    <!--<message clIEntCredentialType="None" />-->                </security>            </binding>        </wshttpBinding>    </bindings>    <services>        <service behaviorConfiguration="NewBehavior0" name="_20180420_WcfServicelibraryTest.Service1">            <endpoint address="" binding="wshttpBinding" bindingConfiguration="wshttpBindingConf"          name="WCFEndpoint" contract="_20180420_WcfServicelibraryTest.IService1">                <IDentity>                    <dns value="localhost" />                </IDentity>            </endpoint>            <endpoint address="mex" binding="mexhttpsBinding" bindingConfiguration=""          name="mexEndPoint" contract="IMetadataExchange" />            <host>                <baseAddresses>                    <add baseAddress="https://localhost:8722/Design_Time_Addresses/_20180420_WcfServicelibraryTest/Service1/" />                </baseAddresses>            </host>        </service>    </services></system.serviceModel>

阅读SO并尝试我发现的每件事我尝试了很多配置.但没有一个显示出值得一提的进步.看起来更像,我不知道.
使用wshttpBinding使最基本的W工作(在SoapUi中编译可测试)的正确配置是什么?

解决方法 我想这可能是因为mex bindingConfiguration =“”被设置为一个空字符串?
尝试删除它,或将其设置为绑定.

如果默认的mexhttpBinding不起作用,请尝试将其更改为wshttpBinding.这是一个可能有用的示例Custom Secure Metadata Endpoint.它说:

In many of the other samples,the Metadata endpoint uses the default mexhttpBinding,which is not secure. Here the Metadata is secured using WShttpBinding with Message security. In order for Metadata clIEnts to retrIEve this Metadata,they must be configured with a matching binding.

需要为不同的绑定配置WCF测试客户端,但我认为它会自动配置自己.

<services>       <service name="Microsoft.ServiceModel.Samples.CalculatorService"               behaviorConfiguration="CalculatorServiceBehavior">       <!-- use base address provIDed by host -->       <endpoint address=""         binding="wshttpBinding"         bindingConfiguration="Binding2"         contract="Microsoft.ServiceModel.Samples.ICalculator" />       <endpoint address="mex"         binding="wshttpBinding"         bindingConfiguration="Binding1"         contract="IMetadataExchange" />       </service>   </services>   <bindings>     <wshttpBinding>       <binding name="Binding1">         <security mode="Message">           <message clIEntCredentialType="Certificate" />         </security>       </binding>       <binding name="Binding2">         <reliableSession inactivityTimeout="00:01:00" enabled="true" />         <security mode="Message">           <message clIEntCredentialType="Certificate" />         </security>       </binding>     </wshttpBinding>   </bindings>
总结

以上是内存溢出为你收集整理的c# – 使用wsHttpBinding配置WCF服务全部内容,希望文章能够帮你解决c# – 使用wsHttpBinding配置WCF服务所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1233144.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存