代码之家  ›  专栏  ›  技术社区  ›  landyman

WCF Web服务在Azure中遇到404

  •  0
  • landyman  · 技术社区  · 15 年前

    我刚开始使用WCF和Azure,但我有一个WCF Web服务,在Visual Studio中调试时可以正常工作。我将启动项目设置为Azure,对于我尝试的任何与服务相关的URL,都会收到404个错误。

    以下是我认为的相关代码: 来自IWebService.cs

    [OperationContract]
    [WebGet(UriTemplate = "GetData/Xml?value={value}", ResponseFormat=WebMessageFormat.Xml)]
    string GetDataXml(string value);
    

    从Web.config:

    <system.serviceModel>
      <services>
        <service name="WebService" behaviorConfiguration="WebServiceBehavior">
          <!-- Service Endpoints -->
          <endpoint address="" binding="webHttpBinding" contract="IWebService" behaviorConfiguration="WebEndpointBehavior"></endpoint>
          <endpoint address="ws" binding="wsHttpBinding" contract="IWebService"/>
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
      </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="WebServiceBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="true"/>
          </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
          <behavior name="WebEndpointBehavior">
            <webHttp/>
          </behavior>
        </endpointBehaviors>
      </behaviors>
    </system.serviceModel>
    

    我试过将绑定改为“basicHttpBinding”,但那没有成功。

    提前感谢您的帮助!

    1 回复  |  直到 6 年前
        1
  •  1
  •   landyman    15 年前

    再挖几下,我就开始工作了。 我必须这么做:

    1. 以管理员身份运行Visual Studio命令行。
    2. 转到C:\Windows\Microsoft.NET\Frameword v3.0\Windows Communication Foundation
    3. 运行“servicemodelreg-i”

    这将安装查看服务所需的所有内容。