【问题标题】:Azure WCF https 404 errorAzure WCF https 404 错误
【发布时间】:2012-12-21 18:27:50
【问题描述】:

编辑 如果我尝试在没有 https 的情况下访问 /dowork 的 Web 服务端点,我仍然会收到错误消息,但它会识别出有效的端点。如何启用 HTTPS?

我有一个 WCF 服务,它最终将主要接收 AJAX 调用以根据用户行为管理状态。

目前,我无法找回任何东西,你能看出我哪里出错了吗? (site/core.svc/dowork 在浏览器和 ajax 中都失败)

[ServiceContract]
public interface Icore
{
    [OperationContract]
    [WebInvoke(UriTemplate = "/dowork",
        BodyStyle = WebMessageBodyStyle.Wrapped,
        ResponseFormat = WebMessageFormat.Xml)]
    string DoWork();
}

[System.Web.Script.Services.ScriptService]
public class core : Icore
{
    public string DoWork()
    {
        return "hullo";
    }
}

  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <customErrors mode="Off"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
    <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <bindings>
      <webHttpBinding></webHttpBinding>
    </bindings>
    <services>
      <service name="Fusion.core" behaviorConfiguration="Fusion.CoreBehavior" >
        <endpoint contract="Fusion.Icore" binding="webHttpBinding" behaviorConfiguration="webBehavior" address="" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Fusion.CoreBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="webBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

【问题讨论】:

  • 您是否连接到 https 端点?您是否在 中配置了传输模式安全性?或者,如果您点击 http 端点,您会看到它的工作原理吗?
  • 我试过干预它,但我得到了同样的效果。我可以直接去 core.svc 就好了。

标签: jquery wcf azure https


【解决方案1】:

您是说“site/core.svc/dowork 在...浏览器中失败”,这意味着您正在使用 HTTP GET 访问该服务。但是,您的合约使用启用 HTTP POST 的 [WebInvoke]。尝试将 [WebInvoke] 更改为 [WebGet] 并查看它是否会更改浏览器中的任何内容。

【讨论】:

  • 遗憾的是,事实并非如此 :( 我同意你的说法,即这是错误的,但我想我会期待 404 错误以外的其他内容。
  • 实际上,如果是方法不匹配,我很确定它是 404。如果不是这样,我能想到的下一件事就是评论者 Praburaj 指出的“安全模式=“运输””(请参阅​​taciturndiscourse.com/services/ssl-for-webhttpbinding)。您说您尝试过“干预”,但您是否可以实际编辑您的问题以反映这两个修复(WebInvoke->WebGet 和传输安全),以便我们能够查看“干涉”?
猜你喜欢
  • 1970-01-01
  • 2023-03-21
  • 1970-01-01
  • 2016-03-17
  • 2014-05-06
  • 1970-01-01
  • 2017-03-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多