【问题标题】:WebGet with UriTemplate doesn't create the correct end-point带有 UriTemplate 的 WebGet 不会创建正确的端点
【发布时间】:2013-06-17 13:46:46
【问题描述】:

我可以访问我的 WCF 服务并获取它的 WSDL 文件,但不能访问它的“子目录”。当我在地址栏中输入 URL 时收到的错误如下。

[14:42:45.509] GET http://---.azurewebsites.net/MyService.svc/Ping [HTTP/1.1 400 错误请求 105ms]

接口和实现如下。

[OperationContract]
[WebGet(UriTemplate="Ping")]
String Ping();

public String Ping() { return "Pong"; }

配置文件中的服务模型由以下部分组成。

行为

<behaviors>
  <endpointBehaviors>
    <behavior name="PingEndPointBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name ="PingServiceBehavior">
      <serviceMetadata httpGetEnabled="true" 
                       httpsGetEnabled="true"/>
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" 
                       httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

绑定

<bindings>
  <basicHttpBinding>
    <binding name="PingBasicHttpBinding"/>
  </basicHttpBinding>
</bindings>

服务

<services>
  <service name="MyNamespace.MyService" 
           behaviorConfiguration="PingServiceBehavior">
    <endpoint name="PingEndpoint" 
              behaviorConfiguration="PingEndPointBehavior" 
              address="Ping" 
              bindingConfiguration="PingBasicHttpBinding" 
              contract="MyNamespace.IMyService"/>
  </service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
                           multipleSiteBindingsEnabled="true"/>

我错过了什么?

【问题讨论】:

  • 我猜您无法键入 URL 并使用 BasicHttpBinding 从您的 WCF 服务获得响应。您应该使用 webHttpBinding 来完成上述工作
  • @Rajesh Put 作为回复,所以我可以检查它是否为绿色。

标签: c# wcf web-config


【解决方案1】:

我猜您无法键入 URL 并使用 BasicHttpBinding 从您的 WCF 服务获得响应。您应该使用webHttpBinding 来实现上述功能

【讨论】:

  • 我纠正了这个错误,但我不确定我是解决了问题还是只是把它扫到了地毯下,因为现在我发现没有找到终点。我发布了related question here,但到目前为止,没有人提出任何评论,这让我很担心。随意尝试一下。我可能会为此提供一些赏金,因为它对我来说非常重要。 :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-07-31
  • 1970-01-01
  • 2016-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-09
相关资源
最近更新 更多