Geo*_*ge2 16 .net c# wcf wshttpbinding visual-studio-2008
我正在使用VSTS 2008 + C#+ .NET 3.0.我正在使用自托管的WCF服务.执行以下语句时,会出现以下"未找到绑定"错误.我发布了我的整个app.config文件,任何想法有什么问题?
ServiceHost host = new ServiceHost(typeof(MyWCFService));
Run Code Online (Sandbox Code Playgroud)
错误信息:
无法通过绑定MetadataExchangeHttpBinding找到与端点的方案http匹配的基址.注册的基地址方案是[https].
完整的app.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyBinding"
closeTimeout="00:00:10"
openTimeout="00:00:20"
receiveTimeout="00:00:30"
sendTimeout="00:00:40"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="WeakWildcard"
maxReceivedMessageSize="100000000"
messageEncoding="Mtom"
proxyAddress="http://foo/bar"
textEncoding="utf-16"
useDefaultWebProxy="false">
<reliableSession ordered="false"
inactivityTimeout="00:02:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Digest"
proxyCredentialType="None"
realm="someRealm" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyWCFService"
behaviorConfiguration="mexServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://localhost:9090/MyService"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyBinding" contract="IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
Run Code Online (Sandbox Code Playgroud)
mar*_*c_s 45
您的服务的基地址定义"HTTPS://" - 但您的mex地址是"HTTP".
如果您希望您的服务使用https://,您还需要使用mexHttpsBinding:
<services>
<service name="MyWCFService" behaviorConfiguration="mexServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://localhost:9090/MyService"/>
</baseAddresses>
</host>
<endpoint address=""
binding="wsHttpBinding"
bindingConfiguration="MyBinding"
contract="IMyService"
/>
<endpoint address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange"
/>
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
渣
blo*_*art 13
我可以获得双倍分数吗?:)
当您使用WS-Http时,您将绑定到HTTPS协议,因此您需要使用正确的MEX绑定;
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
35882 次 |
最近记录: |