简体   繁体   English

WCF Web.Config问题

[英]WCF Web.Config Question

I decided to migrate my legacy web service over to a WCF service called ServiceZ.svc. 我决定将旧的Web服务迁移到名为ServiceZ.svc的WCF服务。 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. 尽管移动一切顺利,并且应用程序已编译,并且我的开发计算机上运行了其他WCF TCP服务,但无法加载此HTTP WCF服务。 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? 无论我如何尝试,我都会不断收到404错误-有人可以查看包含的web.config部分并帮助我找出问题所在吗? 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) In the serviceBehaviors I tend to add the following within the behavior: (completely optional) 1)在serviceBehaviors中,我倾向于在行为内添加以下内容:( 完全可选)

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

This makes the service accessible with either a query using localhost , localserver1 , www.webserver2.com , or fully.qualified.domain.com . 这使得该服务可以通过使用localhostlocalserver1www.webserver2.comfully.qualified.domain.com的查询来fully.qualified.domain.com (Makes for less headaches IMHO). (减少头痛恕我直言)。

2) The endpoint addresses are relative to the baseAddress. 2)端点地址是相对于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" 也就是说,假设baseAddress="http://localhost:__PORT__/Website/ServiceZ"您可以将address=""用于默认绑定,将address="mex"用于mexHttpBinding。

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) 您的WSDL问题很可能是由于两个问题的混合(基本上,该服务说所有标记都可以在本地主机上找到(由端点地址指定))-在本地运行时是正确的,但是在本地运行时在远程服务器上不再是这种情况)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM