[英]WebGet with UriTemplate doesn't create the correct end-point
我可以訪問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"/>
我想念什么?
我猜您不能使用BasicHttpBinding
鍵入URL並從WCF服務獲得響應。 您應該使用webHttpBinding
使上面的工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.