3

我正在开发一个 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:--"

我已经添加了aspNetCompatibilityEnabled="true"wcf 服务路由的属性,如果该属性已被删除,一切正常。最初,此服务已配置为basicHttpBinding& 有同样的问题。读完这篇文章后,我已经更改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>
4

0 回答 0