wsHttpBinding(使用https和aspNetCompatibilityEnabled进行路由)元数据错误302

时间:2012-12-19 15:10:48

标签: wcf https basichttpbinding wshttpbinding

我正在开发一个WCF服务,该服务与带有https端口的ASP.NET MVC 2应用程序一起运行,该端口已使用webMatrix-ssl证书进行配置。该服务在浏览器中运行良好,也可以下载wsdl。但是当我尝试将服务加载到wcftestclient工具以及我自己的客户端时,得到以下错误。

Error: Cannot obtain Metadata from 'localhost:44300/MyService' If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error    URI: localhost:44300/MyService    Metadata contains a reference that cannot be resolved: 'localhost:44300/MyService'.    The remote server returned an unexpected response: (302) Found.    Too many automatic redirections were attempted.HTTP GET Error    URI: localhost:44300/MyService    There was an error downloading 'localhost:44300/MyService'.    The request failed with the error message:--"

我为wcf服务路由添加了属性aspNetCompatibilityEnabled="true",如果该属性已被删除,则一切正常。最初,此服务已配置basicHttpBinding&有同样的问题。阅读此article后,我已更改为wshttpBinding,因为怀疑绑定也可能是问题,仍然遇到同样的问题,下面是我的web.config

请有人帮我修理一下吗?

<system.serviceModel>    
    <extensions>
      <behaviorExtensions>
        <add name="ExceptionBehavior" type="ServiceExceptionHander.ExceptionHandlerBehaviorExtension, ServiceExceptionHandler" />
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
          <ExceptionBehavior />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="ServiceImplementation.MyService" behaviorConfiguration="ServiceBehavior">
        <endpoint binding="wsHttpBinding" bindingConfiguration="securityBinding" contract="ServiceContracts.IMyServiceContracts"/>    
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>    
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="securityBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>          
        </binding>
      </wsHttpBinding>   
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true">
      <serviceActivations>
        <add factory="System.ServiceModel.Activation.ServiceHostFactory" service="ServiceImplementation.MyService" relativeAddress="MyService.svc"/>
      </serviceActivations>
    </serviceHostingEnvironment>    
</system.serviceModel>

0 个答案:

没有答案