本文介绍了WCF 服务在方法请求上返回 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个仅通过 SSL 运行 WebGets/WebInvokes 的 WCF 服务页面 - 它在我的本地机器上运行良好(自签名证书).但是,在生产环境中,我可以访问 service.svc(并且它给了我关于如何使用的消息)但 service.svc/AnyRequest 返回 404.这两种环境都托管在 IIS 7.5 中.

I have a WCF service page running only WebGets/WebInvokes over SSL - it works fine on my local machine (self signed cert). On production, however, I can reach service.svc (and it gives me the message about how to consume) but service.svc/AnyRequest returns a 404. Both environments are hosted in IIS 7.5.

我启用了跟踪,该服务甚至没有接收任何方法请求(例如 service.svc/SomeRequest),但是它正在处理 service.svc 就好了.它也在监听 https://computername.domain.net/path/service.svc - 这正常吗?它通常应该指向 https://public faces.com/path/service.svc 吗?

I've enabled tracing and the service isn't even picking up any of the method requests (e.g. service.svc/SomeRequest), however it is processing service.svc just fine. It's also listening at https://computername.domain.net/path/service.svc - is this normal? Should it normally be pointing to https://publicfacing.com/path/service.svc?

另请注意,生产服务器在 IIS 中托管多个站点.

Also note that the production server is hosting multiple sites within IIS.

下面是我的 web.config 的 system.serviceModel 部分.从此处建议使用 SSLBehave.

Below is the system.serviceModel section of my web.config. The SSLBehave was suggested from here.

  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"></transport>
          </security>
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SSLBehave">
          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <add scheme="https" port="443"/>
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="UserManagement.ajaxAspNetAjaxBehavior">
          <webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
      multipleSiteBindingsEnabled="true" />
    <services>
      <service name="UserManagement.ajax" behaviorConfiguration="SSLBehave">
        <endpoint address="" behaviorConfiguration="UserManagement.ajaxAspNetAjaxBehavior"
          binding="webHttpBinding" bindingConfiguration="TransportSecurity" contract="UserManagement.ajax" />
      </service>
    </services>
  </system.serviceModel>

推荐答案

我会从检查一些事情开始;

I would start by checking a number of things;

  • 对托管目录的权限?
  • .Net 版本是否正确?
  • 您是否已将证书添加到站点?
  • 尝试将图像放在同一路径中,您可以导航到该路径吗(排除奇怪的偶然路径映射)

祝你好运!

这篇关于WCF 服务在方法请求上返回 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 15:56