简体   繁体   中英

WebGet with UriTemplate doesn't create the correct end-point

I can access my WCF service and obtain its WSDL file but can't access a "subdirectory" to it. The error recieved is as follows when I type in the URL in the address line.

[14:42:45.509] GET http://---.azurewebsites.net/MyService.svc/Ping [HTTP/1.1 400 Bad Request 105ms]

The interface and implementation is as follows.

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

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

The service model in the config file consists of the following section.

Behaviors

<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

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

Services

<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"/>

What am I missing?

I guess you cannot type the URL and get a response from your WCF service using BasicHttpBinding . You should use webHttpBinding for the above to work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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