WCF Web.Config 问题 [英] WCF Web.Config Question

查看:28
本文介绍了WCF Web.Config 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定将我的旧 Web 服务迁移到名为 ServiceZ.svc 的 WCF 服务.虽然移动没有任何问题并且应用程序编译并且我的开发机器上运行了其他 WCF TCP 服务,但我无法加载这个 HTTP WCF 服务.无论我尝试什么,我都会收到 404 错误 - 有人可以查看包含的 web.config 部分并帮助我找出问题所在吗?谢谢!

I decided to migrate my legacy web service over to a WCF service called ServiceZ.svc. While moving things over went off without any issues and the application compiles AND I have other WCF TCP services running on my development machine, I cannot get this HTTP WCF service to load. I keep getting 404 errors no matter what I try - can somebody please review the included web.config section and help me figure out what is wrong? Thanks!

<system.serviceModel>  
    <services>  
      <service name="ServiceZ">  
        <endpoint address="http://localhost/Website/ServiceZ" binding="basicHttpBinding"
          name="MainHttpPoint" contract="IServiceZ" />  
        <endpoint address="mex" binding="mexHttpBinding" name="MexEP"  
          contract="IMetadataExchange" />  
        <host>  
          <baseAddresses>  
            <add baseAddress="http://localhost/Website/ServiceZ" />  
          </baseAddresses>  
        </host>  
      </service>  
    </services>  
    <bindings>  
      <basicHttpBinding>  
        <binding openTimeout="0:10:00" sendTimeout="00:10:00" />  
      </basicHttpBinding>  
    </bindings>  
    <behaviors>  
      <serviceBehaviors>  
        <behavior>  
          <serviceMetadata httpGetEnabled="true" />  
          <serviceDebug includeExceptionDetailInFaults="false" />  
        </behavior>  
      </serviceBehaviors>  
    </behaviors>  
  </system.serviceModel>

推荐答案

根据您要如何配置,您可以采用以下方法:

Depending how you want to configure this, you can take the following approach:

1) 在 serviceBehaviors 中,我倾向于在行为中添加以下内容:(完全可选)

1) In the serviceBehaviors I tend to add the following within the behavior: (completely optional)

<useRequestHeadersForMetaAddress>
  <defaultPorts>
    <add scheme="http" port="__PORT__" />
  </defaultPorts>
</useRequestHeadersForMetaAddress>

这使得服务可以通过使用 localhostlocalserver1www.webserver2.comfully 的查询访问.合格的.domain.com.(恕我直言,可以减少头痛).

This makes the service accessible with either a query using localhost, localserver1, www.webserver2.com, or fully.qualified.domain.com. (Makes for less headaches IMHO).

2) 端点地址是相对于 baseAddress 的.也就是说,您可以使用 address="" 作为默认绑定,将 address="mex" 用于 mexHttpBinding,鉴于 baseAddress="http://localhost:__PORT__/Website/ServiceZ"

2) The endpoint addresses are relative to the baseAddress. That as to say you can use address="" for your default binding and address="mex" for your mexHttpBinding, given that baseAddress="http://localhost:__PORT__/Website/ServiceZ"

很可能您的 WSDL 问题是由于这两个问题的混合(基本上,服务说所有标记都可以在本地主机上找到(由端点地址指定)--这是当您在本地运行它时为真,但是当它在远程服务器上时则不再如此)

Most likely your WSDL problem is due to a mix of the two problems (basically, the service is saying all markup can be found on localhost (as specified by the endpoint address)--which is true when you run it locally, however when it's on a remote server this is no longer the case)

这篇关于WCF Web.Config 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆